开发者

how to format the hint displayed inside a html form field?

开发者 https://www.devze.com 2023-03-06 02:24 出处:网络
There was a question previously on how to show hints in a text field (html form field), which clears automatically when the user clicks on the field under consideration. As in, when the field gets foc

There was a question previously on how to show hints in a text field (html form field), which clears automatically when the user clicks on the field under consideration. As in, when the field gets focus, the hint displayed inside the form gets cleared without the user having to开发者_开发问答 manually delete the characters.

The solution given (and it works perfectly) -

<input onfocus="if (this.value=='search') this.value = ''" type="text" value="search">

Now my question is, how do you format the text that is displayed as the hint (in this case "search"). By formatting, i would want it to be in a certain color and font type.

I can do this to the other fields, which do not have this preloaded hint in it, by using css- color:#123123; font-family:calibri;

Thanks!


You're asking about styling the content (value) of an input element.

You can use regular CSS for this:

input {
  color:#123123;
  font-family:Calibri;
}

Working example: http://jsfiddle.net/fxxp4/

0

精彩评论

暂无评论...
验证码 换一张
取 消