HTML <input> readonly Attribute
Definition and Usage
readonly
The property specifies that the input field is read-only.
readonly
The property is a boolean property.
If this property is set, it specifies that the input field is read-only.
Read-only input fields cannot be modified (but users can navigate to it using the tab key, highlight it, and copy the text from it).
can be set readonly
attribute to prevent the user from changing the value until certain other conditions are met (such as checking a checkbox, etc.). Then, JavaScript can delete readonly
the value and make the input field editable.
Note:The form will still submit the read-only input field, but will not submit the disabled input field!
Example
This HTML form contains a read-only input field:
<form action="/action_page.php"> <label for="country">Country:</label> <input type="text" id="country" name="country" value="China" readonly><br><br> <input type="submit" value="Submit"> </form>
Syntax
<input readonly>
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |