{"id":20834,"date":"2013-03-27T16:17:47","date_gmt":"2013-03-27T23:17:47","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=20834"},"modified":"2021-01-07T08:08:56","modified_gmt":"2021-01-07T16:08:56","slug":"placeholder","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/selectors\/p\/placeholder\/","title":{"rendered":"::placeholder"},"content":{"rendered":"\n

The ::placeholder<\/code> pseudo element (or a pseudo class, in some cases, depending on the browser implementation) allows you to style the placeholder text of a form element. As in, the text set with the placeholder<\/code> attribute:<\/p>\n\n\n\n

<input type=\"email\" placeholder=\"jane@firefly.com\"><\/code><\/pre>\n\n\n\n

You can style that text across most browsers with this smattering of vendor-prefixed selectors:<\/p>\n\n\n\n

::-webkit-input-placeholder { \/* Chrome\/Opera\/Safari *\/\n  color: pink;\n}\n::-moz-placeholder { \/* Firefox 19+ *\/\n  color: pink;\n}\n:-ms-input-placeholder { \/* IE 10+ *\/\n  color: pink;\n}\n:-moz-placeholder { \/* Firefox 18- *\/\n  color: pink;\n}<\/code><\/pre>\n\n\n\n

Important warning:<\/strong> this syntax is non-standard, thus all the naming craziness. It doesn’t appear in the spec at all. :placeholder-shown<\/code> is standard, and even spec authors seem to think ::placeholder<\/code> will be the standardized version.<\/p>\n\n\n\n

Like any psuedo, you can scope it to specific elements as needed, like:<\/p>\n\n\n\n

input[type=\"email\"].big-dog::-webkit-input-placeholder {\n  color: orange;\n}<\/code><\/pre>\n\n\n

Demo<\/h3>\n\n\n