These attributes are called Boolean attributes - and, unofficially, in some places, proprietary.
As predicted 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 backwards compatibility, the attribute has also been preserved for the attribute being able to receive a nonempty string with the same attribute name.
Therefore, required
and required="required"
are valid attributes.
In the specification itself says:
The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.
That is, values like "true"
and "false"
are not allowed in boolean attributes (in others, yes). To set it to false, simply omit the attribute of the element.
So,
<input type="checkbox" checked name="cheese" disabled>
It is equivalent to
<input type="checkbox" checked="checked" name="cheese" disabled="disabled">
In addition, you can 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 though it's forecasted, the specification turns out to be just a suggestion of standardization, which does not mean that all browsers will implement it faithfully. I believe all major current browsers will see "true"
as true, but this can change without notice in any version, in any browser. There's no reason to use it.