Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make preview text in form italic

I have a script that erases the default value text in the form when the user clicks in the field, but how can I make the value text appear in italics? If I change the input in my CSS to font-style: italic then when the user types it appears in italics too and I just want the "preview text" to be in italics and then normal when the user is typing.

like image 353
Tyler Avatar asked Oct 21 '25 18:10

Tyler


1 Answers

Style the ::placeholder pseudo-element for the field:

.field::placeholder {
  font-style: italic;
}
<input type="email" class="field" placeholder="[email protected]">

<input type="email" class="field" placeholder="[email protected]"
       value="[email protected]">
like image 147
Ry- Avatar answered Oct 24 '25 10:10

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!