Drupal - Overriding style sheets from modules and drupal core

Option 1
To override a core or contributed module style sheet, it must be specified in your theme's .info file.
For example, system-menus.css is located at "modules/system/system-menus.css". If you place a file with the same name in your theme's folder and add the following entry to the .info file, the original system-menus.css file will be ignored and your version will be loaded in its place.

1.stylesheets[all][] = node.css
2.stylesheets[all][] = defaults.css
3.stylesheets[all][] = system.css
4.stylesheets[all][] = system-menus.css
5.stylesheets[all][] = user.css

Adding the override for a style sheet that does not exist inside the theme will omit the core or module style sheet.

Option 2
This can achieved using the preprocess function also, which should be written in your theme's template.php file

<?php
   
/**
    * Override or insert PHPTemplate variables into the templates.
    */
  
function phptemplate_preprocess_page(&$vars) {
  
// get all the CSS file which are loaded
  
$css = drupal_add_css();
  
// since all the CSS files loaded from the modules will be done using the tag 'module'
   // clear the module CSS files
  
$css["all"]["module"] = array();
  
// re-assign the CSS files to the styles varaible
  
$vars["styles"] = drupal_get_css($css);
  }
?>

Remember to clear your cache after making this change! Navigate to Administer > Site configuration > Performance. Scroll to the bottom and click, "Clear cached data."

Share Your Answers

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.