English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <textarea> readonly attribute

The readonly attribute is a boolean attribute. The readonly attribute specifies that the text area should be read-only. In a read-only text area, the content cannot be changed, but users can tag it, highlight it, and copy content from it.

 HTML <textarea> tag

Online Example

A read-only text area:

<textarea readonly>
HTML is called HyperText Markup Language, which is a tagging language. It includes a series of tags. Through these tags, the format of documents on the network can be unified, making scattered Internet resources connect into a logical whole.3codebox.com basic tutorial
</textarea>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the readonly attribute.

Definition and Usage

The readonly attribute is a boolean attribute.

The readonly attribute specifies that the text area should be read-only.

In a read-only text area, content cannot be changed, but users can tag, highlight, and copy content from it.

The readonly attribute can be set to prevent users from using the text area until other conditions are met (such as checking a checkbox, etc.). Then, JavaScript needs to be used to remove the read-only value and make the text area editable.

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, attribute abbreviations are prohibited, the readonly attribute must be defined as <textarea readonly="readonly">.

Syntax

<textarea readonly>
 HTML <textarea> tag