Drupal Dilatant: How to Add Additional Stylesheets to Drupal 6x
I am not a techie. So maybe that’s the problem. But I can swear that time and time again I read material meant to teach about Drupal development that actually confuses me more.
Today I wanted to add an additional stylesheet to a theme. This stylesheet is meant to cascade below the main (default) stylesheet to overwrite styles that I want to change. I never (at least try to never) touch the default stylesheet, a lesson learned through many painful upgrade ordeals. If you mess with the default sheets, then at upgrade time you have to search for and transfer all those changes to the new theme that comes with major upgrades. So I’ve learned to just get Drupal to pull in my custom “style_ali.css” sheet to import below the main sheet, overwriting styles I specify in it.
So I go to this page: http://drupal.org/node/171209 meant to tell us how to add a stylesheet.
Find the .info file in your theme’s directory and add stylesheet, using the following method:
stylesheets[all][] = name_of_stylesheet.css
But read the text and it says, “Keep in mind that defining custom styles will prevent the default style.css from loading.”
Well, hello? I don’t want to disable the main sheet. Very few people would want to do that. The whole power of CSS is in its ability to cascade styles over each other.
Thankfully, a good soul from New Zealand (http://drupal.org/node/171209#comment-1039677) clarifies that adding another line of stylesheet with a different name simply adds custom styles and does not disable style.css.
So my code for adding my own custom styles, to appear after the default style.css, is this:
stylesheets[all][] = style.css
stylesheets[all][] = style_ali.css
It works. Style.css, the stylesheet that came with theme, does its work. Then style_ali.css kicks in and add its own styles and, if I care to, overwrites defaults styles with the same name.
DISCLOSURE: I am NOT a Drupal expert. My posts about Drupal are meant to impart how-to info in plain English on methods that have worked for me. My target audience is people who, like myself, use Drupal as just one of the tools to leverage the Web — hence the name DrupalDilatant.