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



Readonly attribute in html

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:

readonly Attribute Code Explanation

  1. This <input> tag has the default value “Wikitechy”.
  2. This <input> tag has the default value “Wikitechy” and it also has the readonly attribute.

Output for readonly Attribute in HTML:

readonly Attribute Tag Output

  1. The output shows the both two textboxes has the value “Wikitechy”.
  2. readonly Attribute Tag Output

  3. 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

Related Searches to readonly Attribute in html