W3Schools.com

HTML5 <input> readonly Attribute

HTML5 input Tag Reference HTML5 <input> tag

Example

An HTML form with a read-only input field:

<form action="demo_form.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 works in all major browsers.


Definition and Usage

The readonly attribute is a boolean attribute.

When present, it specifies that an input field is read-only.

A read-only input 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 conditions have been met (like selecting a checkbox, etc.). Then, a JavaScript can remove the readonly value, and make the input field editable.


Differences Between HTML 4.01 and HTML5

None.


Syntax

<input readonly="readonly" />

Note: The readonly attribute is a boolean attribute, and can be set in the following ways:

  • <input readonly>
  • <input readonly="readonly">
  • <input readonly="">

HTML5 input Tag Reference HTML5 <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