Can I use the function menu_tree() in Drupal 7 to customize a menu and add CSS classes? I've tried to customize a main_menu by adding CSS classes: Is it the right way?

1 Answer 1


The easiest way to add custom classes to menu items in Drupal 7 is the Menu Attributes module.

If you really want to do this programmatically, then you can override the theme_menu_link() function in your theme's template.php file. Be sure to read the drupal.org documentation on Overriding Themable Output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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