HTML readonly Attribute Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The HTML readonly attribute, when applied to input fields or text areas, prevents users from editing the content, allowing it only for viewing purposes.Syntax<input readonly>Supported Tags This attribute is used with two elements which are listed below:ElementDescription<input>Used with the readonly attribute for read-only input fields.<textarea>Utilized with the readonly attribute for read-only text areas.HTML readonly Attribute ExamplesExample1: 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>GeeksForGeeks</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 readonly Attribute example outputExample2: In this example we are using the readonly attribute in a <textarea>, preventing user editing and allowing viewing of pre-filled content about GeeksForGeeks. html <!DOCTYPE html> <html> <head> <title>readonly attribute</title> </head> <body> <h1>GeeksForGeeks</h1> <h2> readonly attribute in input Element </h2> <textarea rows="4" cols="40" readonly> GeeksForGeeks is a good website for learning computer science. It is a computer science portal for geeks. </textarea > </body> </html> Output: HTML readonly Attribute example outputSupported Browsers: The browsers supported by readonly attribute are listed below:Google ChromeEdge Firefox OperaSafari Comment More infoAdvertise with us M manaschhabra2 Follow Improve Article Tags : Technical Scripter Web Technologies HTML Technical Scripter 2018 HTML-Attributes +1 More Explore HTML Tutorial 11 min read BasicsHTML Introduction 5 min read HTML Editors 5 min read HTML Basics 7 min read HTML Structure & ElementsHTML Elements 5 min read HTML Attributes 8 min read HTML Headings 4 min read HTML Paragraphs 5 min read HTML Text Formatting 4 min read HTML Block and Inline Elements 3 min read HTML Charsets 4 min read HTML ListHTML Lists 5 min read HTML Ordered Lists 5 min read HTML Unordered Lists 4 min read HTML Description Lists 3 min read HTML Visuals & MediaHTML Colors 11 min read HTML Links Hyperlinks 3 min read HTML Images 7 min read HTML Favicon 4 min read HTML Video 4 min read HTML Layout & DesignHTML Tables 10 min read HTML Iframes 4 min read HTML Layout 4 min read HTML File Paths 3 min read HTML Projects& Advanced TopicsHTML Forms 5 min read HTML5 Semantics 6 min read HTML URL Encoding 4 min read HTML Responsive Web Design 11 min read Top 10 Projects For Beginners To Practice HTML and CSS Skills 8 min read HTML Tutorial ReferencesHTML Tags - A to Z List 15+ min read HTML Attributes Complete Reference 8 min read HTML Global Attributes 5 min read HTML5 Complete Reference 8 min read HTML5 MathML Complete Reference 3 min read HTML DOM Complete Reference 15+ min read HTML DOM Audio/Video Complete Reference 2 min read SVG Element Complete Reference 5 min read SVG Attribute Complete Reference 8 min read SVG Property Complete Reference 7 min read HTML Canvas Complete Reference 4 min read Like