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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/attributes/html-readonly-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics