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?

Joonas
  • 7,227
  • 9
  • 40
  • 65
user1753622
  • 287
  • 3
  • 19

1 Answers1

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:

Community
  • 1
  • 1
Tomas Ramirez Sarduy
  • 17,294
  • 8
  • 69
  • 85