HTML5 semantic structuring of article and section on web site with multiple sub levels
Question
Which of the following - if any - is the most correct way of using the article and section elements on a web site with multiple sub levels?
The first example creates this flat outline like this.
- Company Name
- Segment Navigation
- Segment Name
- Segment Sub Navigation
- Product Name
- Product Sub Page Navigation
- Product sub page 1 title
- Footer
...and looks like this
<header> <!-- MAIN NAVIGATION -->
<h1><a>Company Name</a></h1>
<nav>
<h1>Segment Navigation</h1>
<ul>
<li><a>Segment 1</a></li>
<li><a>Segment 2</a></li>
<li><a>Segment 3</a></li>
</ul>
</nav>
</header>
<header> <!-- SUB NAVIGATION -->
<h1><a>Segment Name</a></h1>
<nav>
<h1>Segment Sub Navigation</h1>
<ul>
<li><a>Product 1</a></li>
<li><a>Product 2</a></li>
<li><a>Product 3</a></li>
</ul>
</nav>
</header>
<header> <!-- PRODUCT PAGE NAVIGATION -->
<h1><a>Product Name</a></h1>
<nav>
<h1>Product Sub Page Navigation</h1>
<ul>
<li><a>Product sub page 1</a></li>
<li><a>Product sub page 2</a></li>
<li><a>Product sub page 3</a></li>
</ul>
</nav>
</header>
<article>
<h1>Product sub page 1 title</h1>
<p>Content from Product sub page 1<p>
</article>
<footer>
<h1>Footer</h1>
<p>Footer content</p>
</footer>
The second example creates a tree structure outline like this
- Company Name
- Segment Navigation
- Segment Name
- Segment Sub Navigation
- Product Name
- Product Sub Page Navigation
- Product sub page 1 title
- Footer
...and looks like this
<header> <!-- MAIN NAVIGATION -->
<h1><a>Company Name</a></h1>
<nav>
<h1>Segment Navigation</h1>
<ul>
<li><a>Segment 1</a></li>
<li><a>Segment 2</a></li>
<li><a>Segment 3</a></li>
</ul>
</nav>
</header>
<section> <!-- SEGMENT SECTION -->
<header> <!-- SUB NAVIGATION -->
<h1><a>Segment Name</a></h1>
<nav>
<h1>Segment Sub Navigation</h1>
<ul>
<li><a>Product 1</a></li>
<li><a>Product 2</a></li>
<li><a>Product 3</a></li>
</ul>
</nav>
</header>
<section> <!-- PRODUCT SECTION -->
<header> <!-- PRODUCT PAGE NAVIGATION -->
<h1><a>Product Name</a></h1>
<nav>
<h1>Product Sub Page Navigation</h1>
<ul>
<li><a>Product sub page 1</a></li>
<li><a>Product sub page 2</a></li>
<li><a>Product sub page 3</a></li>
</ul>
</nav>
</header>
<article>
<h1>Product sub page 1 title</h1>
<p>Content from Product sub page 1<p>
</article>
</section>
</section>
<footer>
<h1>Footer</h1>
<p>Footer content</p>
</footer>
Solution
Both are fine, but mean different things. Go with whichever outline matches your intent for the structure.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow