Boolean Attributes, Yes they are completely valid.
From W3C: (On SGML & HTML)
Some attributes play the role of boolean variables (e.g., the selected attribute for the
OPTION
element). Their appearance in the start tag of an element implies that the value of the attribute is "true". Their absence implies a value of "false".Boolean attributes may legally take a single value: the name of the attribute itself (e.g.,
selected="selected"
).
This states that Boolean attributes are valid in HTML4 as well, but if you use something like, would be invalid.. because that boolean belongs to option
tag.. Thanks to @Ronni Skansing for clarifying the doubt..
<p selected>Hello</p>
HTML5 Docs :
From W3C :
Empty Attribute Syntax
Certain attributes may be specified by providing just the attribute name, with no value.
From W3C: (HTML 5.1 Nightly )
A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
BUT
is an invalid attribute, if you want to define your own attributes, HTML5 provides a way to do that.. you need to use section
data-
prefix, for example, your should be written as section
data-section
, this way your attribute will be counted as valid.
If you hesitate to do so, we always have a validator to check - W3C Markup Validation Service
^ Validated As HTML5
NOTE: Though I provided
data-
is applicable for HTML5, using custom attributes in HTML4 is invalid, no matter even if you definedata-
before the attribute name, but, boolean attributes are valid in HTML4 as well.