Such attributes are called boolean attributes - and, unofficially, in some places, owned.
As stated in the specification, only the presence of the attribute is already sufficient to consider as true, as well as its absence as false. In addition, to maintain retro-compatibility, the standard of the attribute being able to receive a string not empty with the same attribute name.
Therefore, required
and required="required"
are valid attributes.
In the specification itself it says:
The values "true" and "false" are not allowed on Boolean Attributes. To represent a false value, the attribute has to be omitted altogether.
I mean, values like "true"
and "false"
are not allowed in boolean attributes (in others, yes). To set to false, just omit the element attribute.
Thus,
<input type="checkbox" checked name="cheese" disabled>
Is equivalent to
<input type="checkbox" checked="checked" name="cheese" disabled="disabled">
You can even mix the patterns and omit the quotes:
<input type=checkbox checked=checked name=cheese disabled>
See working:
<input type="checkbox" checked name="cheese" disabled> Sem valores
<input type="checkbox" checked="checked" name="cheese" disabled="disabled"> Com valores
<input type=checkbox checked=checked name=cheese disabled> Misturado
Even if foreseen, the specification turns out to be only one suggestion of standardization, which does not mean that all browsers will implement it faithfully. I believe all major current browsers will consider "true"
as true, but this can change without notice in any version, in any browser. There is no reason to use.
Out of curiosity, where did you see this message?
– Woss
Not really an error, it would be more like a warning message, gets exclamation signal inside a yellow triangle next to the line numbering.
– LeAndrade
But where is this exclamation mark? In the console, in the validator in W3.org?
– Guilherme Nascimento
Next to the IDE’s own line numbering.
– LeAndrade