RSS Feed

Change placeholder color with CSS

Ronny,

Comments
Tip

 

One of the new neat attributes added to input fields in HTML5 is the placeholder attribute. It saves us the hassle of using JavaScript to empty and repopulate fields with grey text when they don't hold a user-entered value.

But what if you fancy hotpink for your placeholders over grey?

The solution is adding these two vendor-prefixed psuedo selectors (works on Webkit & Mozilla browsers):
 
Note: Do not combine these two selectors together. Browsers are required to drop rules when they reach an 'invalid' selector, so doing this ensures it works nowhere.

What do you think?