How to add css class to block using mytheme_preprocess_block() hook? I need to add some css classes to each list item in a menu block that I created. I thought I could accomplish this by using the following code: 

function mytheme_preprocess_block(&amp;$vars) {

  if ($vars['block_html_id'] == 'block-menu-block-7') {
    $i = 1;
    foreach ($vars['elements']['#content'] as $key =&gt; &amp;$item) {
      // get each list item and add some css
      if (strpos($key, '#') === FALSE) {
        $item['#attributes']['class'][] = 'col-' . $i++;
        if ($i &gt; 3) {
          $i = 1;
        }
      }
    }
  }
}


However when I try this, I do not see the new class being added when I inspect the element although it does look like it is being added with this code. What am I doing wrong? I am using Drupal 7 by the way.

Thanks.
function MYTHEME_preprocess_block(&amp;$vars) {
  if ($vars['block_html_id'] == 'block-menu-block-7') {
    $vars['classes_array'][] = 'CSS_CLASS_NAME';
  }
}


If you want to add a class to each individual item (li or/and a)use something like this:

function MYTHEME_menu_link(array $variables) {
  // replace MENU-MACHINE-NAME appropriately
  if ($variables['element']['#original_link']['menu_name'] == 'MENU-MACHINE-NAME') {
    // Add menu-li class to each li 
    $variables['element']['#attributes']['class'][] = 'menu-li';
    // Add menu-li-a class to each anchor link
    $variables['element']['#localized_options']['attributes']['class'][] = 'menu-li-a';
  }
  return theme_menu_link($variables);
}