Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 406
    Quick heads-up (not a solution, just a FYI): if I recall correctly, input[placeholder] just matches <input> tags that have a placeholder attribute, it doesn't match the placeholder attribute itself.
    – pinkgothic
    Commented Apr 9, 2010 at 19:58
  • 10
    @MathiasBynens The :placeholder-shown pseudo-class matches an input element that is showing such placeholder text. So it matches <input> tag, like input selector, but showing placeholder text just now. It also doesn't match the placeholder attribute itself.
    – HEX
    Commented Jan 18, 2016 at 12:55
  • 8
    @HEX It’s not like the input selector because that selects all input elements. :placeholder-shown only selects input elements that are currently showing the placeholder, allowing you to style those elements only, and effectively style the placeholder text. What are you trying to say? Commented Jan 19, 2016 at 14:19
  • 5
    @HEX (Of course, it also selected textarea elements that are showing placeholder text.) Commented Jan 21, 2016 at 10:18
  • 7
    I can see no problem here ... The placeholder's text color is now red. Maybe other modern browsers now support it. Commented May 24, 2017 at 5:28