When you use the WordPress menu system and wp_nav_menu()
function in your theme, menus will by default get wrapped in a <DIV>
container. Since wp_nav_menu()
displays list items, this ends up outputting invalid HTML. A <DIV>
is not allowed as a direct descendant of a <UL>
element.
Since this is invalid HTML, you’ll probably see an error validating your website:
Element div not allowed as child of element ul in this context.
In order to get rid of the container <DIV>
, you can specify an empty container value in wp_nav_menu()
:
1 | wp_nav_menu( array( 'menu' => 'mymenu', 'container' => '') ); |
Now just make sure it didn’t FUBAR your CSS, and you should be all set.