HTML readonly Attribute
Example
<form action="action.php">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname" value="John" readonly><br>
<input type="submit" value="Submit">
</form>
Meaning
The readonly attribute prevents the form control’s value from being changed.
Standard Syntax
HTML: <element readonly>
XHTML: <element readonly="readonly">
Applies to:
The readonly attribute can be used on the following element:
| Element | Attribute |
|---|---|
| <input> | readonly |
| <textarea> | readonly |
Advertisement
Attribute Values
| Value | Description |
|---|---|
| readonly | This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. |