Will CSS 3 still allow omitting final semicolons?

前端 未结 3 2092
春和景丽
春和景丽 2020-12-07 01:35

There seems to be a breaking (i.e. backwards-incompatible) change in the CSS Syntax Module Level 3 specification upcoming draft: trailing semicolon after the last declaratio

3条回答
  •  执笔经年
    2020-12-07 01:45

    Looks like there currently is an ambiguity in the spec.

    You correctly pointed out that 2. Syntax Description section prescribes ending every rule with a semicolon:

    Each declaration has a property name, followed by a colon and the property value, and finished with a semicolon.

    And at the same time, description of the parsing automaton in section 3.6.8. Declaration-value mode reads that a closing brace without a semicolon correctly ends a declaration and current rule at the same time:

    } 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.

    So according to 3.6.8 trailing semicolon is optional.

    I can't say about actual intention of the specification authors. But current situation should probably be reported and fixed. Most certainly they don't have intention of breaking the compatibility with CSS 2.1 and will reword their Syntax Description section in the final version.

提交回复
热议问题