: 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>
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.
More posts by @Radia820
2 Comments
Sorted by latest first Latest Oldest Best
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
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.