At 05:24 AM 6/5/2005, Ian Sweeney wrote:
td#advert {width: 234px;}

Could that rule not simply be

#advert {width: 234px;}

Since #advert should refer to a unique identifier, why does the selector
specify the 'td'?

At 06:10 AM 6/5/2005, Neal Watkins wrote:
td#advert is has a higher specificity and in case there is a conflict
(it does happen) it will apply over #advert


Another reason why one might specify the tag name with its id in the stylesheet, in addition to ratcheting up the specificity in the cascade, is to aid human documentation -- to remind ourselves which tags we're styling. The kinds of rules we'd apply to td#advert are significantly different from the ones we'd apply to p#advert or span#advert, and seeing the tag name in the stylesheet can speed thinking and reduce errors.

This reasoning probably isn't rigorously defensible and some folks may decry it, since specifying the tag name does affect the program logic and documentation should never interfere with functionality, but when "all else is equal" I confess I indulge in the practice...

Sometimes during early development I find it useful NOT to specify a tag name if I'm still playing around with the markup. I can change the HTML from <div id="bob"> to <p id="bob"> without having to cross and dot quite as many t's and i's in the stylesheet.

Can, in fact, the elimination of tag names from the stylesheet be defended as a greater degree of separation of content from presentation?

Paul

______________________________________________________________________
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/

Reply via email to