
- 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 placeholder Attribute
The placeholder attribute of the <input> element is used to set a hint for the input that would give a short description about what is expected in that particular input. This attribute works for the following input types − text, url, search, email, password and tel. It introduced in HTML5.
Following is the syntax −
<input placeholder="placeholder_text">
Here, placeholder_text is the short hint i.e. placeholder which would be visible to the users whenever they will visit that web page.
Let us now see an example to implement the placeholder attribute of the <input> element −
Example
<!DOCTYPE html> <html> <body> <h2>Register</h2> <form action="" method="get"> Id − <input type="text" name="id" placeholder="Enter UserId here..."><br> Password − <input type="password" name="pwd" placeholder="Enter password here..."><br> DOB − <input type="date" name="dob"><br> Telephone − <input type="tel" name="tel" placeholder="Enter mobile number here..."><br> Email − <input type="email" name="email" placeholder="Enter email here..."><br><br> <button type="submit" value="Submit">Submit</button> </form> </body> </html>
Output
In the above example, we have a form with some fields −
<form action="" method="get"> Id − <input type="text" name="id" placeholder="Enter UserId here..."><br> Password − <input type="password" name="pwd" placeholder="Enter password here..."><br> DOB − <input type="date" name="dob"><br> Telephone − <input type="tel" name="tel" placeholder="Enter mobile number here..."><br> Email − <input type="email" name="email" placeholder="Enter email here..."><br><br> <button type="submit" value="Submit">Submit</button> </form>
The placeholder is set for all the fields like −
<input type="password" name="pwd" placeholder="Enter password here...">
Just use the placeholder attribute and set the short hint −
placeholder="Enter password here..."
- Related Articles
- HTML placeholder Attribute
- HTML placeholder Attribute
- 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 placeholder property
- How to use placeholder attribute in HTML?
- HTML input readonly Attribute
- HTML input value Attribute
- HTML DOM Textarea placeholder Property
- How to use different step attribute in one range input in HTML?
- How to change the color of the placeholder attribute with CSS?
- Using CSS :placeholder-shown to Customize Styles for Empty Text Input

Advertisements