HTML readonly attribute
Example
An HTML form with a read-only input field:
Try it »
Browser support





All major browsers support the readonly attribute.
Definition and Usage
The readonly attribute is a boolean attribute.
The readonly attribute specifies that the input field is read-only.
A read-only field cannot be modified. However, the user can still use the tab key to switch to the field, and can select or copy its text.
The readonly attribute prevents the user from modifying the value until certain conditions are met (such as a checkbox being checked). Then, JavaScript can be used to remove the readonly value and switch the input field to an editable state.
Differences between HTML 4.01 and HTML5
none.
Differences between HTML and XHTML
In XHTML, attribute minimization is forbidden, and the readonly attribute must be defined as .
Syntax
HTML tag