The Low Down
readonly attribute makes a form control non-editable (or “read only”).
- A read-only field can’t be modified, but, unlike
disabled, you can tab into it, highlight it, and copy its contents.
- Setting the value to null does not remove the effects of the attribute. Instead use
- You can target elements that are read only with the
:read-onlypseudo-class, and its writability with the
:read-writepseudo-class. Or, if you want to specifically target the presence of the attribute, you can use
readonlyis only relevant for type
text, search, url, tel, email, number, password, and the date/time input types. It is also valid on
readonlyis ignored for type
hidden, range, color, checkbox, radio, file, button, submitand