W3C home > Mailing lists > Public > www-style@w3.org > June 2013

[css-syntax][css-variables] Extend !important to !<anything>*

From: Simon Sapin <simon.sapin@exyr.org>
Date: Fri, 14 Jun 2013 13:04:16 +0100
Message-ID: <51BB06C0.4030701@exyr.org>
To: www-style <www-style@w3.org>

I think we should generalize the !important syntax to enable more 
annotations of the same kind. We should do it now, even if we donít 
define any such annotation yet.

Immediate proposal:

   Change <any-value> in Variables to not accept a top-level '!' token. 
This reserves '!' in a declaration value followed by anything, for 
future extension.

Later proposal:

   Instead of an "important" flag, declarations at the Syntax level have 
a set of "annotations". The order of annotations is not significant. 
Each annotation is a list of component values, like the declaration value.

   Parsing is changed so that in any declaration, a top-level '!' 
<delim> token ends the declaration value or current annotation and 
starts a new annotation, which continues until the next annotation or 
until the declaration ends (at a top-level semicolon, end of the current 
block/function, or EOF.) Expressed as a grammar:

   <declaration> = <declaration-name> <whitespace>* ':'
                   [ '!' <declaration-annotation> ]*
   <declaration-name> = <ident>
   <declaration-value> = <any-value>
   <declaration-annotation> = <any-value>
   <any-value> as in Variables, with top-level '!' also disallowed.

   The initial '!' or a token that ends the declaration are not part of 
the annotation. A declaration without any '!' token has no annotation 
(ie. an empty set.)

   An unknown or invalid annotation makes the declaration invalid and 
ignored, just like with declaration values. In CSS 2.1, Cascade L3 or 
Variables L1, the only know annotation is "important". It is only valid 
on property declarations that take part in the cascade. Future levels 
and other specs can define additional annotations.


We have ideas around for Variables L2 [1] that add annotations such as 
!default and !type(color) to Custom Property declarations. The 
"immediate proposal" makes sure that such declarations are invalid in 
Variables L1, rather than having annotations be part of the variableís 
value. This maintains the rule that declarations using unsupported 
features are ignored. I think itís important to do this before Variables 
L1 goes to CR.

[1] See Tabís last few slides in

Even if we end up not defining new annotations ever, I think the impact 
of the "immediate proposal" on Variables L1 is small enough, and 
compatible with the current definition of !important. (There is no 
impact on other parts of CSS, since a new annotation is already invalid 
in other properties and descriptors.)

The "later proposal" lays the ground work in Syntax for when we actually 
want to add new annotations, and can wait until then. The details are 
open to change.

Simon Sapin
Received on Friday, 14 June 2013 12:04:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:31 UTC