
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Textarea readOnly Property
The HTML DOM Textarea readOnly property returns and modify whether the content of a text area element in an HTML document should be read only or not.
Syntax
Following is the syntax −
1. Returning readOnly
object.readOnly
2. Adding readOnly
object.readOnly = true | false
Let us see an example of HTML DOM Textarea readOnly Property −
Example
<!DOCTYPE html> <html> <style> body { color: #000; background: lightseagreen; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; } </style> <body> <h1>DOM Textarea readOnly Property Demo</h1> <textarea rows="5" cols='20' name="I'm name attribute of textarea element"> Hi! I'm a text area element with some dummy text. </textarea> <button onclick="set()" class="btn">Toggle Read Only</button> <script> function set() { var ta = document.querySelector("textarea"); if (ta.readOnly === true) { ta.readOnly = false; } else { ta.readOnly = true; } } </script> </body> </html>
Output
Click on “Toggle Read Only” button to toggle the value of readOnly attribute of the textarea element.
- Related Articles
- HTML DOM Textarea cols Property
- HTML DOM Textarea rows Property
- HTML DOM Textarea placeholder Property
- HTML DOM Textarea disabled Property
- HTML DOM Textarea defaultValue Property
- HTML DOM Textarea name Property
- HTML DOM Textarea wrap Property
- HTML DOM Textarea autofocus Property
- HTML DOM Textarea form Property
- HTML DOM Textarea required Property
- HTML DOM Textarea maxLength Property
- HTML DOM Input Month readOnly Property
- HTML DOM Input Number readOnly Property
- HTML DOM Input Password readOnly property
- HTML DOM Input Date readOnly Property

Advertisements