Additional styles sheets can be added to the array by using the drupal_add_css() function:
// Repeat this line for every CSS file added.
drupal_add_css(path_to_theme() . '/example.css', 'theme', 'all', TRUE);
// Reassemble the $styles snippet to include the new files.
$styles = drupal_get_css();
In this example, example.css is retrieved from the theme folder. Alternatively, style sheets can be placed in the files directory and accessed by leaving off the path_to_theme() function and using the 'files/subdirectory/example.css' notation.
The drupal_add_css() function can take the following optional parameters:
- Path to the style sheet file (Relative to the base_path())
- Type of style sheet being added (module or theme)
- Style sheets are called in order starting with the system styles sheets, then the module style sheets, and then the theme style sheets. If a style sheet was created to override the CSS that came before it, using the theme option will append it to end of the array and will be called last.
- The Media that the style sheet should be applied to (all, screen, print, handheld, etc.)
- The Preprocess option will aggregate and compress the style sheet if this feature has been turned on under the performance section (TRUE, FALSE)
For Drupal 4.7.x
print theme('stylesheet_import', base_path() . path_to_theme() . '/your_extra.css');
So this is the order we end up with:
- module CSS (for example, event.css from event.module)
- theme CSS (for example, your_extra.css)
- style CSS (style.css files from any theme)
Style sheets can override rules applied in any CSS which precedes them. (i.e. style CSS can override everything else, except for user CSS)