Shovel
Can't get enough of FH
- Joined
- Dec 22, 2003
- Messages
- 1,350
Here in the interests of replacing Joomla tech support with some meatier discussion on Web Development best practices, how to you arrange your CSS file(s) when building a new site?
At present, with an inherited Wordpress template I'm stuck with a bit of cludge and have a single 'style.css' and a couple of overrides in a <style> block in the head. However, that is so far from my ideal that it makes me feel dirty just describing it.
More idealistically, my arrangement goes like this:
The HTML document(s) link to a single CSS file for all media types. This isn't 100% efficient for bandwidth, since @media switching is done after downloading the file, but I find it makes reuse of styles much easier. On occasion I might separate print stylesheets out completely if they are to have a completely different look.
Then it works like this. The first stylesheet (linked to from the HTML) contains colours and borders. Because it's linked in the most legacy-friendly way, it will be interpretted by all browsers back as far as Netscape 4.
The actual layout for the page is loaded up using @import, since Netscape ignores. This way I can use a advanced CSS layout for modern browsers that degrades nicely back to single column display in Netscape.
There're two more CSS files: One for typography and another for hacks. By keeping hacks separated, it allows some degree of cleanliness in the other files, and means there's only a single point-of-failure should a browser hack cease working or cause problems elsewhere.
I avoid using <style /> elements in full sites, since that defeats the purpose of separating content and presentation, although it is useful if creating a single-file demonstration for something. I absolutely refuse to use hacks in my mark-up, though (conditional comments be damned).
Finally, I never name any of the files 'style.css'. It's generic to the point of useless. As much as a 'CSS Stylesheet' is already a redundent abbreviation, 'style dot cascading stylesheet stylesheet' goes too far. I tend to give the initial file a 'theme' name (often just the name of the site, so 'benward.css'), and then layout.css, type.css and hacks.css respectively.
How do you roll yours?
At present, with an inherited Wordpress template I'm stuck with a bit of cludge and have a single 'style.css' and a couple of overrides in a <style> block in the head. However, that is so far from my ideal that it makes me feel dirty just describing it.
More idealistically, my arrangement goes like this:
The HTML document(s) link to a single CSS file for all media types. This isn't 100% efficient for bandwidth, since @media switching is done after downloading the file, but I find it makes reuse of styles much easier. On occasion I might separate print stylesheets out completely if they are to have a completely different look.
Then it works like this. The first stylesheet (linked to from the HTML) contains colours and borders. Because it's linked in the most legacy-friendly way, it will be interpretted by all browsers back as far as Netscape 4.
The actual layout for the page is loaded up using @import, since Netscape ignores. This way I can use a advanced CSS layout for modern browsers that degrades nicely back to single column display in Netscape.
There're two more CSS files: One for typography and another for hacks. By keeping hacks separated, it allows some degree of cleanliness in the other files, and means there's only a single point-of-failure should a browser hack cease working or cause problems elsewhere.
I avoid using <style /> elements in full sites, since that defeats the purpose of separating content and presentation, although it is useful if creating a single-file demonstration for something. I absolutely refuse to use hacks in my mark-up, though (conditional comments be damned).
Finally, I never name any of the files 'style.css'. It's generic to the point of useless. As much as a 'CSS Stylesheet' is already a redundent abbreviation, 'style dot cascading stylesheet stylesheet' goes too far. I tend to give the initial file a 'theme' name (often just the name of the site, so 'benward.css'), and then layout.css, type.css and hacks.css respectively.
How do you roll yours?