1. Technology
Send to a Friend via Email

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

readonly - HTML Attribute for Forms


Readonly Attribute Description:

The readonly attribute makes form controls such as the INPUT or TEXTAREA read only, so the user cannot change the contents.

This attribute is valid in HTML5.

The Readonly Attribute is Used with These Tags:

The Readonly Attribute Contains:

This attribute is a boolean attribute. This means that it is either applied or not. So, in HTML it has no value and is applied like this:

<input id=firstname readonly>

In XHTML, you must include a value, so you write:

<input id="firstname" readonly="readonly" />

Readonly Default Value:

The readonly attribute has no default value. If it is present, it is applied to the element and if it is not present, the element can be filled in.

Readonly is Valid in HTML Versions:

  • HTML 3.2
  • HTML 4.01
  • HTMl5
  • XHTML 1
  • XHTML5

Readonly Attribute DTD:


<doctype hmtml>

HTML 4.01 Standard

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

XHTML 1.0 Standard

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

©2014 About.com. All rights reserved.