HTML <textarea> readonly Attribute
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.”
<!DOCTYPE html>
<html>
<head>
<title>
HTML Textarea readonly Attribute
</title>
</head>
<body style="text-align:center">
<p>A readonly Textarea.</p>
<!--A readonly Textarea-->
<textarea readonly>
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.
<!DOCTYPE html>
<html>
<head>
<title>
HTML Textarea readonly Attribute
</title>
</head>
<body style="text-align:center">
<p>A readonly Textbox.</p>
<textarea readonly="readonly"
cols="15"
rows="5">
This textarea can't be edited it is readonly only.
</textarea>
</body>
</html>
Output:
Supported Browsers
The browser supported by <textarea> readonly attribute are listed below: