When I try to validate the following HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test page</title>
</head>
<body>
<input type="text" name="testInput" value="test value" readonly="readonly" style="background-color: #e3e3e3;">
</body>
</html>
The validator gives the error:
Line 8, Column 118: Attribute readonly not allowed on element input at this point.
But in the error details it says:
readonly when type is text, ...
As this is a text input, why am I receiving the validation error?
This is bug in the W3C Markup Validator; I have submitted a bug report .
While waiting for the bug to be fixed (which I expect to happen soon), use the validator.nu service instead.
Update: The bug has now been fixed.
readonly
attribute is only allowed on these input types:
For any other input type like hidden
, you are not allowed to have readonly
in which case you may get:
Error: Attribute readonly not allowed on element input at this point.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.