Search field with placeholder text:
<form action="demo_form.asp" method="get"> <input type="search" name="user_search" placeholder="Search W3School" /> <input type="submit" /> </form>
Definition and Usage
The placeholder property provides a hint that describes the expected value of the input field.
The prompt is displayed when the input field is empty and disappears when the field gets focus.
Note: the placeholder attribute applies to the following < input > types: text, search, URL, phone, email, and password.
Let’s look at the prompt for setting the input text box using the placeholder property
You can use the placeholder property to set the prompt information in the input text box
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> < input type = "text" placeholder = "please enter user name" value = "" / > </body> </html>
As a result, when the content of the text box is empty, the prompt message will be displayed, and when the content is entered, the prompt message will disappear
The difference between the placeholder and the value property is that the value property is set directly to the content in the text box
The above is a tip for you to use the placeholder property to set the input text box. I hope it will help you, and thank you for your support for the developepaer website!