Changing font-family for placeholder

Goldie picture Goldie · Jan 25, 2013 · Viewed 52.6k times · Source

Is it posible for input field to have one font-family and it's placeholder other?

I have tried to change font-family for input's placeholder with already defined @font-face in CSS but it's not working

CSS

.mainLoginInput::-webkit-input-placeholder { 
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}

.mainLoginInput:-moz-placeholder { 
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}

HTML

<input class="mainLoginInput" type="text" placeholder="Username"  />

How can I slove this problem?

Answer

Balthazar picture Balthazar · May 6, 2014

In case someone want the placeholders selectors for all browsers :

.mainLoginInput::-webkit-input-placeholder {
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}

.mainLoginInput:-ms-input-placeholder {
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}

.mainLoginInput:-moz-placeholder {
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}

.mainLoginInput::-moz-placeholder {
  font-family: 'myFont', Arial, Helvetica, sans-serif;
}