开发者

In HTML5, can you nest NAV elements?

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 navs is not allowed. And seeing as <nav> is a block-level element, there is nothing wrong with nesting them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜