[thelist] Another CSS question

Donald Noble donald at drnoble.co.uk
Sun Jan 5 16:13:01 CST 2003

Hi evolters,
just a pondering of mine, when writing css is it better to specify the type
of element it is to be applied to, or just leave the element out...
1) div#alpha{}  or  2) #alpha{}

obviously the first only matches divs, but id's are unique anyway - so that
isn't really an issue

1 reminds you what element alpha is, when looking over the code after some
time, but 2 is less code (perhaps an issue for large css files (and long

I would have thought 1 would be better in terms of browser rendering, as it
limits the elements it may be applied to - but that may well be wrong.

the other thing is nested elements, is it best to put...
3) table tr td p{}  or  4) table p{}  or  5) td p{}

I would think either 4 or 5 depending on the circumstances - but are there
any benefits to using 3?

Does anybody have any comments/hard evidence/anicdotal stories/urban myths
that are relavant, or am I just being pedantic as usual?!?!

cheers :Donald

(also posted to comp.infosystems.www.authoring.stylesheets)

  personal site: http://www.drnoble.co.uk
Hardware, Software, Custom built PC Systems

More information about the thelist mailing list