Open In App

How to style Placeholder Text in an Input Field ?

Last Updated : 01 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Styling placeholder text in an input field in CSS involves using the ::placeholder pseudo-element. This allows you to apply styles specifically to the placeholder text within the input.

Note: The ::placeholder pseudo-element is used to target and style the placeholder text.

Syntax:

/* Styling placeholder text with a different color */
input::placeholder {
  color: #999;
}

/* Changing the font size of placeholder text */
input::placeholder {
  font-size: 14px;
}

Features:

The Features of ::placeholder Pseudo-element:

  • Targets the placeholder text within an input field.
  • Allows customization of properties such as color, font size, font style, etc.
  • Styling placeholder text provides a way to enhance the visual presentation and user experience of input fields in a form.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads