On 16 Dec 2005, at 12:06 am, Adam Kuehn wrote:
>> My second questions is related to that, dose anyone know of any
>> resources on writing more optimised css. For example I was just
>> reading on this list in the talk comparing class to id and there was
>> mention there was performance difference between
>>
>> element.class {}
>> and
>> .class {}
>
> I'm the one who brought up this performance difference, and I was
> careful to qualify that I only knew the facts for one browser (in
> this case, Mozilla). A general attempt to optimize CSS may not even
> be possible. Each browser vendor is free to optimize page display in
> any way they can think of. Because of the specific way that Mozilla
> has optimized selector matching, a class or ID without the element is
> *slightly* faster to match than one that includes the element. That
> may or may not be true with some other browser (and it might be
> difficult to even discover in anything other than an open-source
> implementation, unless you are willing to do brute-force technical
> testing on thousands of combinations).
Some reading matter
<http://developer.mozilla.org/en/docs/Writing_Efficient_CSS>
<http://weblogs.mozillazine.org/hyatt/archives/2005_05.html#007507>
Both by David Hyatt, lead developer of Safari.
Both argue that
element.class and element#id are slightly slower than #id or .class.
This of course does not take into account the various other
environmental variables, as Adam points out.
From a practical point of view, I'd argue for #id or .class rather
than element#id or element.class, because the first notation is less
specific, and hence more easy to override in case of necessity.
Philippe
---
Philippe Wittenbergh
<http://emps.l-c-n.com/>
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/