In this shot, we will learn about the
placeholder attribute in HTML.
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.
text will be displayed to the user until they enter data into the search box.
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”.
View all Courses