I have a site-wide main menu, which I'm currently usi开发者_JS百科ng <nav>
for. I also have a submenu, which is right under the main nav and is different for every product on the site. What's the best practice to handle this?
Currently, I have a separate <div id="secondary-nav">
below the main nav. But since they're both within the <header>
of the page, I was thinking about having a nested <nav>
instead. Is this an OK practice in HTML5?
It's perfectly acceptable to use nav
there. You may also want to look at aside
if it can be removed, or look to use section
tags within the nav
to better divide up the content. This returns to the whole semantics debate, where my stance is, if it makes sense, do it. It doesn't need to be 100% semantically correct, as no one outside of the people who look at source code will ever know.
There is currently nothing in the specs that indicates that nesting nav
s is not allowed. And seeing as <nav>
is a block-level element, there is nothing wrong with nesting them.
精彩评论