布尔属性,是的,它们完全有效.
From W3C:(在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").
这表明布尔属性在HTML4中也是有效的,但是如果你使用类似的东西,则会无效..因为布尔值属于选项标签..感谢@Ronni Skansing澄清疑问..
Hello
HTML5文档:
空属性语法
Certain attributes may be specified by providing just the attribute
name,with no value.
From W3C:(每晚HTML 5.1)
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.
但
section是一个无效的属性,如果你想定义自己的属性,HTML5提供了一种方法来做到这一点..你需要使用data-前缀,例如,你的节应该写成数据节,这样你的属性将是算作有效.
^验证为HTML5
NOTE: Though I provided data- is applicable for HTML5,using custom
attributes in HTML4 is invalid,no matter even if you define data- before the attribute name,but,boolean attributes are valid in HTML4 as well.