HTML readonly Attribute

❮ HTML Attributes

Example

<form action="action.php">
	<label for="fname">First name:</label>
	<input type="text" id="fname" name="fname" value="John" readonly><br>
	<input type="submit" value="Submit">
</form>

Meaning

The readonly attribute prevents the form control’s value from being changed.




Standard Syntax

HTML: <element readonly>
XHTML: <element readonly="readonly">



Browser Support




Status




Applies to:

The readonly attribute can be used on the following element:

Element Attribute
<input> readonly
<textarea> readonly






Attribute Values

Value Description
readonly This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
❮ HTML Attributes