# ::placeholder

> The `::placeholder` CSS pseudo-element styles the placeholder text in input fields and textareas.

## How do I change the placeholder color of an input in CSS?

The pseudo-element used to style the placeholder text within an input or textarea element. It allows changing the appearance of the placeholder, such as its color, font or opacity, without affecting the input text itself.

- Topic: Pseudo Elements
- Type: pseudo-element
- Browser support: Chrome 57+, Chrome Android 57+, Edge 79+, Firefox 51+, Firefox Android 51+, Safari 10.1+, Safari iOS 10.3+

## Example

Wrong:

```css
input::placeholder {
  color: #ccc;
}
```

Right:

```css
input::placeholder {
  color: #6b6b6b;
}
```

`#6b6b6b` stays readable on a white field, while `#ccc` is too faint for many users.

## Common mistakes

- Using the placeholder as the only label, so it disappears once the user types.
- Light gray placeholder text that fails contrast checks.

## Key points

- Placeholder text keeps enough contrast with the field background.
- Fields have a real `<label>`; the placeholder isn't the only label.
- Only text styles are set on `::placeholder`, as box properties like `margin` are ignored.

## Interview questions

### Why shouldn't the placeholder replace a label?

It disappears when the user types, is often low contrast and is not a reliable label. Use a visible `<label>` and keep the placeholder for an example value.

### Which properties work on ::placeholder?

Text and background styles, such as `color`, `font`, `opacity`, `letter-spacing` and `background-color`. Box properties like `margin` and `padding` do not apply.

## Related cards

- [:placeholder-shown](https://wonderium.dev/css/placeholder-shown.md)
- [`<input>`](https://wonderium.dev/html/input.md)
- [`<label>`](https://wonderium.dev/html/label.md)
- [Accessible Forms](https://wonderium.dev/a11y/accessible-forms.md)
- [color](https://wonderium.dev/css/color-property.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/placeholder
- Last updated: 2026-11-25
