Performance: Navigation structure basics
This affects the page's initial load speed and visual stability by how navigation elements are structured and rendered.
<nav><ul><li><a href="#">Home</a></li><li><a href="#">About</a></li><li><a href="#">Contact</a></li></ul></nav>
<div><div>Home</div><div>About</div><div>Contact</div></div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-semantic <div> navigation | Multiple nested divs | Multiple reflows on load | Higher paint cost due to layout shifts | [X] Bad |
| Semantic <nav> with <ul> and <li> | Simple list structure | Single reflow | Lower paint cost, stable layout | [OK] Good |
<nav> element in HTML?<nav><nav> element is designed to group navigation links on a webpage.<nav>.<navigation>, <nav-section>, and <nav-area> are not valid HTML tags.<nav>
<ul>
<li><a href='#home'>Home</a></li>
<li><a href='#about'>About</a></li>
<li><a href='#contact'>Contact</a></li>
</ul>
</nav><nav> with an unordered list <ul> containing list items <li> each with a link <a>.<nav>
<ul>
<li><a href='home.html'>Home</li>
<li><a href='about.html'>About</a></li>
</ul>
</nav><a href='home.html'> but no closing </a> before the </li>.<ul> inside <nav> is valid, <li> is correct, and href values should be quoted.<nav> element with a list (<ul>) of links is the correct semantic structure.Pass the test and this pattern moves unknown