Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML input readonly attribute

HTML readonly attribute

HTML input Tag Reference HTML tag

Example

An HTML form with a read-only input field:

  Country:

 

Try it »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 input Tag Reference HTML tag