W3Schools.com

HTML <input> readonly Attribute

HTML input Tag Reference HTML <input> tag

Example

An HTML form with a read-only input field:

<form action="form_action.asp">
  Country: <input type="text" name="country" value="Norway"
  readonly="readonly" /><br />
  <input type="submit" value="Submit" />
</form>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The readonly attribute is supported in all major browsers.


Definition and Usage

The readonly attribute specifies that an input field should be read-only.

A read-only field cannot be modified. However, a user can tab to it, highlight it, and copy the text from it.

The readonly attribute can be set to keep a user from changing the value until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the readonly value, and make the input field editable.


Syntax

<input readonly="readonly" />

Attribute Values

Value Description
readonly Specifies that an input field is read-only


HTML input Tag Reference HTML <input> tag
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE