154 of 313 menu

The placeholder pseudo-element

The placeholder pseudo-element sets styles for placeholder hint in the input or textarea tags.

Syntax

selector::placeholder { color: red; }

Example

Let's color the hint red:

<input type="text" placeholder="hint"> input::placeholder { color: red; }

:

Example . Hint in textarea

Let's color the hint red in the textarea tag:

<textarea placeholder="hint"></textarea> textarea::placeholder { color: red; }

:

See also

  • attribute placeholder,
    which sets the hint for the input field
  • pseudo-class placeholder-shown,
    which sets the styles for the input field with the hint
byenru