Open In App

HTML <textarea> readonly Attribute

Last Updated : 12 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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>

<body style="text-align:center">
    <p>A readonly Textarea.</p>
    <!--A readonly Textarea-->
    <textarea readonly>
        This textarea field is readonly. 
    </textarea>
</body>

</html>

Output: 

html-textarea-readonly-attribute-example

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>

<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: 

html-textarea-readonly-attribute-example-2

HTML textarea read only attribute

Supported Browsers

The browser supported by <textarea> readonly attribute are listed below: 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads