W3C home > Mailing lists > Public > www-style@w3.org > March 2004

Re: @try in CSS3 (was: Useragent Rules in CSS)

From: <rijk@opera.com>
Date: Wed, 31 Mar 2004 16:04:39 +0000
Message-ID: <1080749079.406aec1781733@sam.opera.com>
To: Chris Moschini <cmoschini@myrealbox.com>
Cc: www-style@w3.org

Quoting Chris Moschini <cmoschini@myrealbox.com>: 
> Christoph Paper:

>> Like already proposed, the minimal solution was a grouping at-rule, like
>>
>> @batch {
>>    foo {property1: value; property2: value}
>> }
>>
>> If the browser can apply *all* rulesets inside, they are, else none of
>> them.
>
> First of all, I realize what this syntax is now - it's essentially multiple
> try blocks.
>
>
>> Can anyone provide an example which this approach cannot solve?
>
> Sadly, I can:
> 
> @try {
> 	#myDiv {
> 		width: 100px;
> 		margin: 1px;
> 	}
> }
> 
> Internet Explorer would incorrectly draw the block 98px wide, even though
> it technically supports all that's in the @try. However - it's better
> than nothing.

Which version of IE? IE 3-6 will not do anything with this rule of course, just
as every other current browser version.

> If I take IE's total profile into account I can lock it out nicely:
> 
> @try {
> 	body>#myDiv {
> 		width: 100px;
> 		margin: 1px;
> 	}
> }
> @catch {
> 	#myDiv {
> 		width: 102px;
> 		margin: 1px;
> 	}
> }
> 
> I like this idea.

Now you are back to square one, using parsing issues and selector-support to
target buggy implementations. You can get the same results by removing the @try
and @catch blocks, and showing the 'good' rules last. Or, for the sake of
argument, by using this sheet:

@batch { 
        #myDiv { 
                width: 98px; 
                margin: 1px; 
        } 
}

@batch { 
        html>body #myDiv { 
                width: 100px; 
                margin: 1px; 
        } 
}

Using all-or-nothing blocks can't, in itself, solve potential future issues like
the boxmodel problem, unless you are still prepared to exploit random parsing
and support issues, like above. But it can help in using new CSS3 properties and
values without messing up styles understood by older browsers, and in making
css-hacks simpler.

To avoid css-hacks all together, you would really need @useragent. As discussed,
it is not likely that would be workable.

-- 
Rijk
Received on Wednesday, 31 March 2004 11:05:52 GMT

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