
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Text placeholder property
The HTML DOM Input Text placeholder property is used for setting or returning the placeholder attribute value of an input text 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.
Syntax
Following is the syntax for −
Setting the placeholder property −
textObject.placeholder = text
Here, text represents the placeholder text specifying the hint for the user about the text field.
Example
Let us look at an example for the input Text placeholder property −
<!DOCTYPE html> <html> <body> <h1>Input Text placeholder property</h1> USERNAME: <input type="text" id="USR" placeholder="...."> <p>Change the placeholder text of the above field by clicking the below button</p> <button onclick="changeHolder()">CHANGE</button> <script> function changeHolder() { document.getElementById("USR").placeholder = "Enter your username here.."; } </script> </body> </html>
Output
This will produce the following output −
Placeholder changed successfully −
- Related Articles
- HTML DOM Input Number placeholder Property
- HTML DOM Input Password placeholder property
- HTML DOM Input Email placeholder Property
- HTML DOM Input URL placeholder Property
- HTML DOM Input Search placeholder property
- HTML DOM Input Text size Property
- HTML DOM Input Text type Property
- HTML DOM Input Text value Property
- HTML DOM Input Text autocomplete Property
- HTML DOM Input Text autofocus Property
- HTML DOM Input Text defaultValue Property
- HTML DOM Input Text disabled Property
- HTML DOM Input Text form Property
- HTML DOM Input Text maxLength Property
- HTML DOM Input Text name Property

Advertisements