Easy Tutorial
❮ Tag Samp Att Input Src ❯

HTML <input> readonly Attribute

HTML <input> Tag

Example

An HTML form with a read-only input field:


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.

Read-only fields cannot be modified. However, users can still tab to the field and select or copy the text.

The readonly attribute prevents the user from modifying the value until certain conditions are met (such as selecting a checkbox). Then, JavaScript needs to be used to remove the readonly value, switching 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 <input readonly="readonly" />.


Syntax


❮ Tag Samp Att Input Src ❯