"empty attribute syntax" 允许哪些 html5 属性?

For which html5 attributes is the "empty attribute syntax" allowed?

http://www.w3.org/TR/html-markup/syntax.html#syntax-attr-empty

Empty attribute syntax

Certain attributes may be specified by providing just the attribute name, with no value [… which] is exactly equivalent to specifying the empty string as the value for the attribute.

IIRC,boolean 属性经常用这个。但是,“某些属性”指的是什么? 在哪些属性、哪些元素上允许使用这种语法? 或者:在哪些地方不允许使用这种语法?

我在任何地方都找不到完整的列表。

空属性语法只是一个 shorthand,用于具有名称和空字符串值的属性,本身并不意味着任何特殊内容。因此,除布尔属性外,任何允许空值的属性(包括 class)都可以使用空属性语法指定,而任何不允许空值的属性(例如 idtype,不能用空属性语法指定。

您可以通过使用 Validator.nu.

比较以下代码段的验证结果来确认这一点

以下两个片段都应验证:

<!DOCTYPE html><title>Test</title>
<body class>
<!DOCTYPE html><title>Test</title>
<body class="">

并且以下两个片段都应该产生相同的验证错误:

<!DOCTYPE html><title>Test</title>
<body id>
<!DOCTYPE html><title>Test</title>
<body id="">

Error: Bad value for attribute id on element body: An ID must not be the empty string.