How to dynamically change the CSS style of a node-type? I want to modify dynamically the style of a page in base of your content type:
I tried with a preprocess function insert this code:

if(isset($variables['node'])){
  if($variables['node']-&gt;type=='article'){
    drupal_add_css(drupal_get_path('theme','my_theme').'/css/style_node_article.css');
  }
  if($variables['node']-&gt;type=='page'){
    drupal_add_css(drupal_get_path('theme','my_theme').'/css/style_node_page.css');
  }
}


This doesn't set the right CSS if I change page from article to page...
Thanks
Unless you have a ton of CSS you should add the CSS for all the nodes and use the node type class on the wrapper div of the node.

I can't remember the exact classes you can view them in the source. You could do something like this

.node {}
.node-page {}
.node-blog {}


Where the first class is on all nodes and the latter is dynamic for the node.