I'd only insert an image in nav
if …
- … this image is linked to a page/anchor (for example a link to the front page), or
- … this image contains the text "Navigation" or similar (so it should be inserted in a
h1
)
The spec says:
The nav
element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.
So this section shouldn't contain things not about navigation.
Your second example is not what you want, because you would create a wrong outline (because of the outer section
).
If it's the main navigation of the page and the image is the site logo, I'd use this markup:
<header>
<h1><a href="index.html" title="Home page"><img src="logo.png" alt="ACME Inc."></a></h1>
<nav>
<ul>
<li>a</li>
<li>b</li>
</ul>
</nav>
</header>
If you'd like to link the logo to the home page and the home page is not linked in the ul
, I'd insert it in the nav
:
<nav>
<ul>
<li><a href="index.html" title="Home page"><img src="logo.png" alt="ACME Inc."></a></li>
<li>a</li>
<li>b</li>
</ul>
</nav>
But this is a rare case, because you would still need a page heading and in most cases this would be the logo, and in most cases this should be linked to the home page of the site.