HTML readonly Attribute

The readonly attribute on an input element specifies that the element is read-only, that is, the element is non-editable. Elements that accept this attribute includes <input> and <textarea>.



A readonly attribute on an <input> element.
The text field is not editable, but its value is included during form submission.

<form action="/tutorial/action.html">
  <label for="title">Title</label><br />
  <input type="text" id="title" name="title"
         value="Of Mice and Men" readonly><br /><br />

  <input type="submit">

For additional details see our HTML input readonly Reference.

Using readonly

The readonly attribute specifies that an input element is read-only.

An element with readonly enabled cannot be modified, but it will send its data when submitted.


<tagname readonly>

Elements that accept readonly

The following input elements accept the readonly attribute.

Elements Description
<input> Specifies an input field -- see example above
<textarea> Creates a multi-line text input field.

<textarea> with readonly

A <textarea> tag with a readonly attribute.
The textarea is not editable but its value will be submitted.

<form action="/tutorial/action.html">
  <label for="summary">Summary</label><br />
  <textarea name="summary"
            rows="5" cols="60" readonly>
Starting with her idyllic life on a sprawling plantation, 
the book traces her survival through the tragic history of 
the South during the Civil War and Reconstruction, and her 
tangled love affairs with Ashley Wilkes and Rhett Butler.
  </textarea><br /><br />
  <input type="submit">

For additional details see our HTML textarea readonly Reference.

Browser support

Here is when readonly support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like