Mobile app version of vmapp.org
Login or Join
Radia820

: Should menu titles (h1, h2, h3...) be inside or outside the tag? Let's say I want to write a simple menu in HTML5. Should I write like this: <h1>My Menu</h1> <h2>Submenu 1</h2>

@Radia820

Posted in: #Html #Html5 #SemanticWeb

Let's say I want to write a simple menu in HTML5.

Should I write like this:

<h1>My Menu</h1>
<h2>Submenu 1</h2>
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
...
</ul>
</nav>
<h2>Submenu 2</h2>
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
...
</ul>
</nav>


Or like this:

<nav>
<h1>My Menu</h1>
<h2>Submenu 1</h2>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
...
</ul>
<h2>Submenu 2</h2>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
...
</ul>
</nav>


In other words, should the titles be inside or outside the <nav> tag?

Thanks.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Radia820

2 Comments

Sorted by latest first Latest Oldest Best

 

@Berumen354

According to the HTML5 spec, "nav" is a "section" and a section "is content that defines the scope of headings and footers." The W3C example for the nav section shows h tags in the the nav.
www.w3.org/TR/html5/sections.html#the-nav-element

10% popularity Vote Up Vote Down


 

@Carla537

h tags are for the structure of the content of the page. I wouldn't say navigation is part of the content of the page, so it doesn't make sense to me to have h tags in the navigation.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme