The HTML readOnly attribute represents that an input/textarea element is read-only that means you can’t modify its content in an HTML document.
Syntax
Following is the syntax −
<tagname readOnly></tagname>
Let us see an example of HTML readOnly Attribute −
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; background-color: #8BC6EC; background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%); text-align: center; } input { display: block; width: 50%; margin: 1rem auto; text-align: center; } </style> <body> <h1>HTML readOnly Demo</h1> <input type="text" value="I'm an input element with readOnly property" readOnly> </body> </html>