HTML readonly Attribute Examples
Example1: In this example we demonstrates the use of the readonly attribute in an input element, making the “Country” input field read-only, while allowing editing for the “Email” field.
html
<!DOCTYPE html> < html > < head > < title >readonly attribute</ title > </ head > < body > < h1 >w3wiki</ h1 > < h2 > readonly attribute in Input Element </ h2 > < form action = "" > Email: < input type = "text" name = "email" /> < br /> Country: < input type = "text" name = "country" value = "Noida" readonly /> < br /> < input type = "submit" value = "Submit" /> </ form > </ body > </ html > |
Output:
html
<!DOCTYPE html> < html > < head > < title >readonly attribute</ title > </ head > < body > < h1 >w3wiki</ h1 > < h2 > readonly attribute in input Element </ h2 > < textarea rows = "4" cols = "40" readonly> w3wiki is a good website for learning computer science. It is a computer science portal for geeks. </ textarea > </ body > </ html > |
Output:
Supported Browsers:
The browsers supported by readonly attribute are listed below:
HTML readonly Attribute
The HTML readonly attribute, when applied to input fields or text areas, prevents users from editing the content, allowing only for viewing purposes.