11

I have an element like this <input type="text" placeholder="lorem ipsum">.

How do I style thisplaceholder attribute in CSS, so that it works across all browsers?

5

1 Answer 1

6

Placeholder text in inputs has (in the browsers implementing it so far) a light gray color. To style it, you'll need vendor prefix CSS properties.

::-webkit-input-placeholder {
   color: red;
}

:-moz-placeholder { /* Firefox 18- */
   color: red;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
}

:-ms-input-placeholder {  
   color: red;  
}

You may also check this very similar question:

Not the answer you're looking for? Browse other questions tagged or ask your own question.