HTML <input> placeholder Attribute
Definition and Usage
placeholder
The attribute specifies a brief hint that describes the expected value of the input field (for example, a sample value or a brief description of the expected format).
This hint will be displayed when the input field is empty and will disappear when the field gains focus.
Note:placeholder
The attribute applies to the following input types:
- text
- search
- url
- tel
- password
Example
Phone input field with placeholder text:
<form action="/action_page.php"> <label for="phone">Please enter the phone number:</label><br><br> <input type="tel" id="phone" name="phone" placeholder="138-8888-8888" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}"><br><br> <small>Format: 138-8888-8888</small><br><br> <input type="submit"> </form>
Syntax
<input placeholder="text">
Attribute Value
Value | Description |
---|---|
text | Specifies a brief hint of the expected value of the input field. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
10.0 | 10.0 | 4.0 | 5.0 | 11.0 |
Note:placeholder
Attributes are new properties in HTML5.