Attribute: Readonly

The readonly attribute specifies that the input field is read only (cannot be changed):

HTML file: Displayed by browser:
<form>
First name:
<br /><input type="text" name="firstname" value="John" readonly>
<br />
<br />Last name:
<br /><input type="text" name="lastname">
</form>
First name:


Last name:

The readonly attribute does not need a value. It is the same as writing readonly="readonly".

Back button Table of Contents Next button