HTML readonly attribute
readonly
The purpose of the HTML readonly attribute is to disallow users to enter data in the associated element.
Supported elements
HTML readonly attribute supports input and textarea elements.
Syntax
<ElementName readonly="value" >.....</ElementName>
Where ElementName is any supported element.
Type of value
Predefined.
Value
readonly.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML readonly attribute with input and textarea elements
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML readonly attribute with input and textarea elements</title>
</head>
<body>
<form name="user_info" action="action.php" method="post">
Name : <input type="text" name="name" readonly="readonly"><br>
email : <input type="text" name="email"><br>
Describe yourself : <br>
<textarea rows="10" cols="10" name="describe_yourself" readonly="readonly">
</textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML readonly attribute with input and textarea elements
Previous: HTML profile attribute
Next: HTML rel attribute
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join