HTML Attributes
HTML readonly attribute
Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. Applicable elements include: <input>, <textarea>. Check each element’s value rules. Boolean syntax: presence enables the state; omit the attribute to disable it. A string value of "false" does not turn it off. Read-only controls that support this attribute can still be focusable and included in form submission; unlike disabled controls, their values are not automatically omitted. It applies to eligible text-like inputs, date/time inputs, number inputs and textarea, not checkbox or select.
Formal Syntax & Structure
html syntaxhtml
readonlyParameters & Attributes
| Name | Type | Description |
|---|---|---|
| readonly | boolean | Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. |
Working Example
Example Snippethtml
<label> Account <input name="account" value="A42" readonly></label>Browser Compatibility
Minimum supported versions across modern rendering engines
Blink (modern)
Chrome
1
Yes
EdgeHTML / Blink
Edge
12
Yes
Gecko
Firefox
1
Yes
WebKit
Safari
1
Yes
Presto / Blink
Opera
≤12.1
Yes
Desktop support for readonly on input only; other elements, input types, individual values and mobile behavior may differ.
HTML Living Standard