Re: [css3-syntax] !important vs. ! /**/ important


Reminder: CSS 2.1 Appendix G allows whitespace and comments between '!' 
and 'important'. There was some discussion of not allowing this in 

Previous discussion starts here:

Test cases: (All green in Gecko, only the last one in WebKit and Presto, 
all red in Trident.)

data:text/html,<p style="color: green !/**/ important; color: red">test
data:text/html,<p style="color: green !/**/important; color: red">test
data:text/html,<p style="color: green ! important; color: red">test

I don’t really care either way, as long as it’s specified. The question 
initially came up in the context of comments in 
CSSSupportsRule.conditionText serialization:

AFAIR the WG still has to decide what to do about this. But in the 
meantime, the ED is inconsistent. §3.6. "Changes from CSS 2.1 Core 
Grammar" has:

> No whitespace or comments are allowed between the DELIM(!) and
> IDENT(important) tokens when processing an !important directive at
> the end of a style rule.

But §3.5.10. "Declaration-important mode" has:

> whitespace token
> comment token
>     Do nothing. Remain in this mode.

Removing one of the quoted parts would make the draft consistent.

If the part in §3.5.10 is removed (ie. no change from CSS 2.1 in parsing 
!important) then comments are ignored in every Tree Construction mode. 
They might as well not be emitted by the tokenizer.

Back to serialization: I guess we need either to make the serializer 
smart about where to insert empty comments (is the serializer specified 
somewhere?), or make comments preserved tokens.

Simon Sapin

Received on Sunday, 27 January 2013 17:51:03 UTC