[thelist] CSS Hack? (was .css files vs inline CSS and .js vs inline JS?)

Sam Foster sam at sam-i-am.com
Tue May 17 23:50:20 CDT 2005


>> Is that truly a hack? Is there a more elegant way to do this?
>
>
> Yup. Add id="home" to the body tag of your home page, then add this to 
> your main stylesheet:
> body#home {
>     background-color: #FFFFFF;
>     background-image: none !important;
> }
>
great, now every single page has to download all this extra fluff. If 
the rule is intended for one page, the rule belongs in the head of that 
page.
For practical purposes, putting it in an external stylesheet can be 
useful - particularly if you aren't the owner of the html (e.g. its 
generated on the server-side, or maintained by someone else)  .. but if 
we are just talking about download speed, cacheing and so on the ideal 
case is that only relevant rules should be downloaded per page.

Ideals rarely come into it however, so do whatever works :)

Sam





More information about the thelist mailing list