I have created one custom module in drupal-7. I want to apply same css to all pages belonging to that module.

I am able to apply css to one page by using drupal_add_css() but not able to do for all pages.


In module's info file, add following line:

stylesheets[all][] = folder/module.css

Substitute folder with a name of subfolder within your module you keep your CSS files in (or remove it). Repeat for all CSS files you need.

More about info files in the manual on Drupal.org.

| improve this answer | |

1- Place style.css in my_module folder

2- in my_modulefolder/my_module.module

function my_module_preprocess(&$vars, $hook) {    
  if($hook == 'page')    
   drupal_add_css(drupal_get_path('module', 'my_module') .'/style.css');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.