W3C home > Mailing lists > Public > www-style@w3.org > February 2008

RE: [css3] Suggestion: Selector variables or "synonyms"

From: Mike Wilson <mikewse@hotmail.com>
Date: Fri, 8 Feb 2008 10:19:43 +0100
Message-ID: <BAY116-DAV94BCF6419D6393872B996A42F0@phx.gbl>
To: <www-style@w3.org>
Message-ID: <019d01c86a33$bda08870$0a01a8c0@mikedeskxp>

I think part of the OP's suggestion correlates to a more
generic feature; inheritance or composition between CSS 
rules. The lack of this causes us to have to repeat 
ourselves when wanting to map property assignments to 
multiple element selections. Example:

  input[type="radio"] {
    color: #444;
    font-size: 77%;
    /*other settings for radio*/
  }
  input[type="checkbox"] {
    color: #444;
    font-size: 77%;
    /*other settings for radio*/
  }

Above we have to repeat the common property assignments. 
As an alternative, they may be extracted to a separate 
rule but then we have to repeat the selectors instead:

  input[type="radio"], input[type="checkbox"] {
    color: #444;
    font-size: 77%;
  }
  input[type="radio"] {...}
  input[type="checkbox"] {...}

Adding the possibility to let one rule inherit the 
property assignments from another rule (or actually 
declaration set) could look something like this:

  .mycolorandfont {
    color: #444;
    font-size: 77%;
  }
  input[type="radio"] {
    INHERIT_DECLS(.mycolorandfont);
    /*other settings for radio*/
  }
  input[type="checkbox"] {
    INHERIT_DECLS(.mycolorandfont);
    /*other settings for radio*/
  }

Note that I am not suggesting any particular syntax here,
it could be using normal classes like above, some new @-
rules, or maybe something completely different based on
object-oriented keywords.

Best regards
Mike Wilson
Received on Friday, 8 February 2008 09:20:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:01 GMT