How to add a css class to the nodes in the front page according to taxonomy of each node in drupal 7? in the front page, I have displayed multiple nodes (article) in the teaser view, each article has taxonomy.

I want to theme each node teaser according to the taxonomy it has, I think it can be done in the theme_preprocess_html(&amp;$variables, $hook), for example

function theme_preprocess_html(&amp;$variables, $hook) {
  if ($variables['is_front']) { 

    // something here, but I don't know what to do
  }
}


the first step is how to find all the nodes in the frontpage, the second is to get the taxonomy of each node, the third is to add the specific css class to each node according to the taxonomy of each node

Does any have suggestions?
Supposing that "field_tags" is the taxonomy field for which you want to use the taxonomy term values, you could use the following code.

function theme_preprocess_html(&amp;$variables, $hook) {
  if ($variables['is_front']) {
    $terms = array();

    foreach ($variables['page']['content']['system_main']['nodes'] as $nid =&gt; $array) {
      $items = field_get_items('node', $array['#node'], 'field_tags');
      foreach ($items as $tid) {
        if (!isset($terms[$tid]) &amp;&amp; ($term = taxonomy_term_load($tid))) {
          $terms[$tid] = drupal_html_class($term-&gt;name);
        }
      }
    }

    if (!empty($terms)) {
      foreach ($terms as $class_name) {
        $variables['classes_array'][] = $class_name;
      }
    }
  }
}