HTML <textarea> readonly Attribute prevents user input, making the textarea content read-only, allowing only the display of text without editing capability.
Syntax:
<textarea readonly> Contents... </textarea>
HTML <textarea> Readonly Attribute Examples
Example 1: In this example we use the readonly attribute within a <textarea> tag, creating an uneditable textarea field displaying the text "This textarea field is readonly."
HTML
<!DOCTYPE html><html><head><title>
HTML Textarea readonly Attribute
</title></head><bodystyle="text-align:center"><p>A readonly Textarea.</p><!--A readonly Textarea--><textareareadonly>
This textarea field is readonly.
</textarea></body></html>
Output:
Example 2: In This HTML example demonstrates the use of the readonly attribute in a <textarea> tag, creating a non-editable textarea with the specified content.
HTML
<!DOCTYPE html><html><head><title>
HTML Textarea readonly Attribute
</title></head><bodystyle="text-align:center"><p>A readonly Textbox.</p><textareareadonly="readonly"cols="15"rows="5">
This textarea can't be edited it is readonly only.
</textarea></body></html>
Output:
HTML textarea read only attributeSupported Browsers
The browser supported by <textarea> readonly attribute are listed below: