比较旧的措辞(W3C Working Draft 13 August 2003):
4.8. Rule sets,declaration blocks,and selectors
A declaration-block (also called a {}-block in the following text) starts with a left curly brace ({) and ends with the matching right curly brace (}). In between there must be a list of zero or more semicolon-separated (;) declarations.
与新的(Editor’s Draft 14 June 2012):
2. Description of CSS’s Syntax
A rule starts with a selector (defined by the Selectors specification),then has a {}-wrapped block containing a sequence of declarations. The selector specifies which elements the declarations will apply to. Each declaration has a property name,followed by a colon and the property value,and finished with a semicolon.
(强调我的).
所以这个漂亮的简短形式,例如:
em { color: lime }
(这在CSS颜色模块3级建议中当然是作为有效的例子)将不再验证?
有可能有更多关于整个3级草稿收藏的知识吗?对于面向未来的样式表,我们真的需要检查现有的CSS文件(如果缺少,请插入分号),然后才能最终确定规范,或者我误解了某些内容?
解决方法
你正确地指出,2. Syntax Description section规定用分号结束每个规则:
Each declaration has a property name,and finished with a semicolon.
同时,第3.6.8. Declaration-value mode节中的解析自动机的描述读取了没有分号的闭括号正确地在同一时间结束声明和当前规则:
} token
Append the current declaration to the value of the current rule. Pop the current rule from the stack of open rules,and append it to the value of the new current rule. Switch to the current rule’s content mode.
所以根据3.6.8的后缀分号是可选的.
我不能说明规范作者的实际意图.但目前的情况应该可以报告和修改.当然,他们没有意图破坏与CSS 2.1的兼容性,并将在最终版本中重写其语法描述部分.