I know that a boolean attribute can optionally have a value. From the HTML5 spec:
The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace. Note: The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.
I suppose there is a valid historical reason that explains why a value is allowed (and only allow a case-insensitive name match)... but my question is: What are the benefits, if any, of having a value for these boolean attributes? (Or disadvantages, if any.)
For example:
<option selected="selected">...</option>
...
<input required="required" ... />
versus
<option selected>...</option>
...
<input required ... />
Aucun commentaire:
Enregistrer un commentaire