html tutorial - readonly Attribute in HTML - html5 - html code - html form

Learn html - html tutorial - Readonly attribute in html - html examples - html programs
- The readonly attribute is used to specify the input field is read-only.
- This is a Boolean attribute.
Syntax for readonly attribute in HTML:
<element readonly>
Applies To:
Element | Attribute |
---|---|
<input> | readonly |
<textarea> | readonly |
Attribute Values:
Value | Description |
---|---|
script | The script can run on readonly |
Sample Coding for readonly Attribute in HTML:
Tryit<!DOCTYPE html>
<html>
<head>
<title>Wikitechy readonly attribute</title>
</head>
<body>
<input type="text" value="Wikitechy" >
<input type="text" value="Wikitechy" readonly >
</body>
</html>
Code Explanation for readonly Attribute in HTML:

- This <input> tag has the default value “Wikitechy”.
- This <input> tag has the default value “Wikitechy” and it also has the readonly attribute.
Output for readonly Attribute in HTML:

- The output shows the both two textboxes has the value “Wikitechy”.
- When the user try to change the text to “Wikitechy Tutorials” First text box text has been changed but the second one not able to edit.

Browser Support for readonly Attribute in HTML:
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
1.0 | 6.0 | 1.0 | 1.0 | 1.0 |