Re: @version rule

The feature is already built in, it's called the cascade and forward
compatible parsing.

Old user agents ignore rules using newer syntax, if you want fall-back
behavior you put it in a rule that would otherwise be overridden by the
cascade.

h1.foo { color: red; } /* a CSS1, 2 or 3 selector */
h1.foo.bar { color: blue; } /* a CSS2 or 3 selector only, CSS1 doesn't allow
multiple classes */

The same can also be done for properties within declarations.

h1 { color: red; color: inherit; } /* CSS1 doesn't allow inherit here so it
will be red, others will inherit */

BTW, CSS3 user agents will still recognize :first-letter as a
pseudo-element. Legacy pseudo-elements are still allowed to use the old
syntax.

Jeffrey Yasskin wrote:

> CSS needs something similar to the xsl:version attribute in XSLT whereby
> a newer user agent can use backwards-compatibility mode for a stylesheet
> written with an older version of CSS.
> For instance, the :first-letter pseudo-element is valid CSS1 but not
> valid CSS3 (it needs to be ::first-letter). A fully compliant browser
> should accept the single-":" form in a CSS1 stylesheet while rejecting
> it in a CSS3 stylesheet.
> CSS could also define a more detailed forward-compatibility mode like
> XSLT's for cases where the UA knows it doesn't support the current
> stylesheet based on the version rule.
> I propose that an @version rule be added of the syntax:
> @version version-string
> Where version-string is the version of CSS the stylesheet is written in.
> "3" for CSS3, "2.1" for a hypothetical CSS 2.1, "17" for CSS17. . .
> If this works:
> Once the version of the entire stylesheet has been established,
> additional @version rules could provide alternative stylesheets for
> downlevel browsers like so:
> <code>
> @version "3";
> /*CSS 3 selectors here*/
> @version "2.1"
> {
>         /*CSS 2.1 selectors here*/
> }
> @version "4"
> {
>         /*Some neat CSS 4 feature that completely breaks backwards
> compatibility*/
> }
> /*More CSS 3 selectors here*/
> </code>
> I don't know how the cascade should work with these rules.
>
> If there's a feature like this already built into CSS, please point me
> to it.
>
> Jeffrey Yasskin

Received on Friday, 27 July 2001 00:23:40 UTC