Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple <nav> tags

Tags:

html

Can we use multiple tags on the same page in html5?

I've read this article on Zeldman.com but it's not entirely clear to me

i.e.

<header><nav>links here</nav></header>  <footer><nav>links here</nav></footer> 
like image 306
stephenmurdoch Avatar asked Jan 13 '11 03:01

stephenmurdoch


People also ask

Can I have multiple NAV tags?

Yes, absolutely. You can have multiple header , nav , and footer tags sans penalty.

How many NAV tags can you have?

You can have as many nav elements as you need in your page, but you don't need to wrap every link or set of links in a nav - only 'major navigation' should be in a nav element.

How do I make multiple navigation bars in HTML?

Create A SubnavUse any element to open the subnav/dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the subnav menu and add the subnav links inside it. Wrap a <div> element around the button and the <div> to position the subnav menu correctly with CSS.

Can you have a NAV inside a NAV?

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.


2 Answers

Yes, absolutely. You can have multiple header, nav, and footer tags sans penalty.

As long as you're making sure you are using tags semantically and you aren't putting them in invalid places (they're block-level elements, so you can't put them inside an inline element, for example) then you shouldn't worry too much about what the sticklers are saying. It's all to easy to get caught up arguing about tiny details instead of moving forward on your project.

like image 141
coreyward Avatar answered Oct 16 '22 16:10

coreyward


Yes, having multiple <nav> elements is absolutely ok.

You just have to make sure you're making them distinguishable for people using screen readers. You can do it by labelling each <nav> using aria-label.

<nav aria-label=’primary’>   <ul>     ...List on links here...   </ul> </nav> <nav aria-label=’secondary’>   <ul>     ...List on links here...   </ul> </nav> 

Or, if one of the <nav> as visible text on screen that can be identified as labelling element, you can use aria-labelledby like follows:

<nav aria-label="Site Menu">   <ul>     ...List on links here...   </ul> </nav> <article>   <h1>Title</h1>   ...   <nav aria-labelledby="id-1">     <h2 id="id-1">       Related Content     </h2>     <ul>       ...List on links here...     </ul>   </nav> </article> 

You can read more about using Multiple Navigation Landmarks.

like image 38
lucalanca Avatar answered Oct 16 '22 17:10

lucalanca