Styling part of the text in the placeholder

前端 未结 2 1411
后悔当初
后悔当初 2020-12-12 02:50

I would like to modify the css style of a part of placeholder. Attention not all the placeholder.

If my placeholder is: \"Wher

2条回答
  •  生来不讨喜
    2020-12-12 03:26

    You may want to think about what the role and meaning of placeholders is. Most UI experts agree: placeholders are not labels. Labels (like "Search") are labels, and should be outside the text area. The placeholder is designed to be a sample input, or a format, not a label, nor instructions. To the extent that you use the placeholder in label-like fashion, that information will disappear as soon as the user starts typing.

    For instance, in an input field for a phone number, the label would be "Phone Number", and the placeholder might be "212-555-1234". In your case, "Search" should be the label, and "brown fox" the placeholder. If you want to make that entire placeholder italics (but why?), you can do that easily enough with the placeholder pseudo-elements.

提交回复
热议问题