W3C home > Mailing lists > Public > www-style@w3.org > September 2011

css-conditional suggestion

From: Nicholas Shanks <contact@nickshanks.com>
Date: Mon, 12 Sep 2011 17:00:15 +0100
Message-ID: <CA+hEJVW2B-R_94ags7a=XJbdwnu4vZ5nxM=L5Mu_Kv2ou11gfg@mail.gmail.com>
To: www-style@w3.org, David Baron <dbaron@dbaron.org>, Ian Hickson <ian@hixie.ch>
While progressive, the CSS3 Conditional Rules Module syntax for author
requirements can get verbose very quickly.

e.g.

@supports (display: inline-block) and (box-spacing: even) /* this list
can get horribly long */ {
    .boxes {
        display: inline-block;
        box-spacing: even;
    }
}


I propose a new, optional, condition keyword: 'all', to be used thus:

@supports all {
    .box {
        display: inline-block;
        box-spacing: even;
    }
}

Which is equivalent to the following:

@supports {
    .box {
        display: inline-block;
        box-spacing: even;
    }
}


The 'all' condition is equivalent to a condition with all contained
properties and values being chained together with 'and'. It is simple,
succinct, and will save CSS authors hours of typing!
The existing syntax remains available for times when, as with Example
VII, vendor prefixes or other more complex conditions using 'or' are
desired.
The 'all' keyword may evoke the CSS2 Media Type of the same name, but
unlike the 'all' media type, '@supports all' is not intended to mean
"supports all of CSS".



The following I am still unsure about:

Should CSS which the UA knows would not be applied in the current
situation, cause the entire ruleset to fail? For example, when
displaying the following *on screen*, should the box-spacing rule be
applied:

@supports all {
    .box {
        display: inline-block;
        box-spacing: even;
    }
    @media print {
        .box {
            paper-tray: 2;
        }
    }
}

Because, if an @-rule is encountered which is not understood (rather
than being understood but not applicable), then the @supports ruleset
must fail:

@supports all {
    .box {
        display: inline-block;
        box-spacing: even;
    }
    @dimensionality (hypercube: 4) {
        .box {
            projection: orthogonal;
        }
    }
}

Therefore, a UA that supports "@media print", but is rendering to
screen, knows it can ignore the "paper-tray" property, regardless of
whether it supports such a property. When the same UA is printing
however, and does NOT support paper-tray, then the entire ruleset
would not get applied.

n.b.  I considered @atomic, or even @supported, but felt the
simplicity of using the same rule name, and potential for confusion
with a variant like @supported, were too great to propose those.

-- 
Nicholas.
Received on Monday, 12 September 2011 16:01:23 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:44 GMT