HTML DOM Input Search placeholder property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Search placeholder property is used for setting or returning the placeholder attribute value of an input search field. The placeholder property is used for giving the web page users a hint about the input element by showing a text inside the input field before the user inputs anything. The placeholder text is greyed by default and isn’t submitted to the form unlike the value property.


Following is the syntax for −

Setting the placeholder property −

searchObject.placeholder = text

Here, text represents the placeholder text specifying the hint for the user about the search field.


Let us look at an example for the input search placeholder property −

Live Demo

<!DOCTYPE html>
<h1>earch placeholder property</h1>
FRUITS: <input type="search" id="SEARCH1" name="fruits">
<p>Change the placeholder text of the above field by clicking the below button</p>
<button onclick="changeHolder()">CHANGE</button>
   function changeHolder() {
      document.getElementById("SEARCH1").placeholder = "Search for the fruits here..";


This will produce the following output −

On clicking the CHANGE button −

Published on 19-Aug-2019 10:08:00