Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development Building Out WordPress Navigation Coding A Basic Navigation in WordPress

Margaret Godowns
Margaret Godowns
6,268 Points

Where does sub-menu styling come from?

I think I'm missing a step here. How does Wordpress know how to style the sub-menu elements? I know we pass the 'no-bullet' class to the ul in the $defaults array, but we don't ever assign a 'sub-menu' class to the sub-menu ul. However, I see that a 'sub-menu' class is present in the markup when I inspect element. Is this something that Wordpess does automatically? Do we just need to include styling for the 'sub-menu' class in our stylesheets?

1 Answer

Hey Margaret,

You are correct, the .sub-menu class comes automatically from WordPress and you'll just need to include styling for it in your stylesheet. Keep in mind that if you have a third-level of menu items, the .sub-menu class will appear again, as it naturally appears for all sub menus of navigation items built with the wp_nav_menu() function. Hope this helps!