Skip to main content
HTML Validation

Bad value X for attribute “readonly” on element “input”.

About This HTML Issue

The readonly attribute is a boolean attribute, so it takes no value: readonly="true" is invalid, and so is any value other than an empty string or readonly itself.

The HTML standard allows three forms for a boolean attribute: the bare name (readonly), an empty value (readonly="") and the name as its own value (readonly="readonly"). Browsers only check whether the attribute is there. readonly="false" still makes the field read-only, which surprises anyone who wrote it to switch the attribute off. To make the field editable, leave the attribute out.

The "true" value usually comes from a template or a JavaScript framework that prints a boolean variable as text, or from markup copied from the DOM, where input.readOnly = true is correct. In HTML, print the attribute when the field should be read-only and skip it when it shouldn't.

Invalid example

<label for="order-id">Order number</label>
<input type="text" id="order-id" name="order-id" value="A-1042" readonly="true">

Valid example

<label for="order-id">Order number</label>
<input type="text" id="order-id" name="order-id" value="A-1042" readonly>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries