Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
communitycreator

What is a placeholder attribute in HTML?

Gutha Vamsi Krishna

In this shot, we will learn about the placeholder attribute in HTML.

A placeholder attribute is used to hint to the user what to enter in the input field.

It can be used in search boxes on web pages. It gives suggestions like “try binary trees” or “search for courses”, etc. to the user to enter.

We can use the placeholder attribute in many scenarios like “Enter email”, “Enter mobile number”, etc.

Syntax

<input placeholder="text">

The text will be displayed to the user until they enter data into the search box.

Example

In the following example, we use an input element to take input from the user. We give the user hints about what to search in the search box by providing the placeholder “Try binary trees”.

Example of placeholder attribute

RELATED TAGS

html
communitycreator
RELATED COURSES

View all Courses

Keep Exploring