I was planning to use the <nav>
tag for a few things, however, the following occurred to me.
Take the following markup for example:
<nav id="sidebar">
<div class="links">
<a href="/"></a>
<a href="/"></a>
<a href="/"></a>
</div>
<div class="links">
<a href="/"></a>
<a href="/"></a>
</div>
<div class="links">
<a href="/"></a>
</div>
<div class="statement">
random content here, unrelated to navigation
</div>
<div class="randomstuff">
unrelated to navigation, but still here
</div>
</nav>
Will search engines respect this sort of usage of semantic tags? By that I mean, "ignore" or lower the priority on all content that's wrapped with a nav tag(even divs and such), even if not directly, or even necessarily all navigational content.
Same question for header
and footer
tags with div
s inside.
Thank you in advance for any assistance.
It doesn't make semantic sense to use NAV around a whole block. Use a generic DIV for layout purposes.
For semantic purposes, you could use multiple NAV elements for sets of links, but the spec is pretty open, so make of it what you will:
You just need to honestly ask yourself, "does this read logically?".
Truth is, there's a lot of HYPE about HTML5 tags. Personally, I think they're a great idea, but in practice, it's only guess work right now as to what search engines do with them.
Hope this helps. Mikey
First of all any content that is unrelated to navigation should not be contained within a
nav
tag.As for what search engines will do with such content should you (or anyone else) have such incorrect markup is anyone's guess.
Short answer: Nobody knows!
You shouldn't include content in
nav
that is not about navigation. Not only the spec is very clear about it, it would harm accessibility, too.So your two
div
elements (.statement
and.randomstuff
) need to get out of thenav
element. Only if they'd be "tangentially related" to the content innav
, you could put the two elements in anaside
element inside ofnav
, but I don't think this is the case for your content.There is no general answer; it depends on your content which element should be used.
You create the overall structure (the document outline) by using the sectioning elements (
section
,article
,nav
,aside
) and headings. Now each section (not to be confused withsection
element!) can haveheader
/footer
elements. That's it. Everything inside a section that is not included inheader
/footer
can be considered the main content of that section. Finer grained elements likeaddress
orsmall
can give additional clues which role their content plays.Now, if something (a search engine, a screenreader, an artifial intelligence, …) wants to consume your document, it might take advantage of your markup. If and to what extent this is the case depends on several factors, like use case, will, skill, costs, etc. So there is no general answer to "Do search engines …?", because a) there are countless search engines (and everyone can create a new one everyday) and b) some (especially the "big players" for general web search) don't like to talk in details about this stuff.
But we can assume what would be useful for all those user-agents/consumers in respect to their use cases:
nav
,aside
,footer
, …)article
higher than insidenav
/aside
header
,footer
,small
andaddress
higher for a navigational search query, and lower for a research querynav
,footer
and top-levelaside
elementsHTML defines the meaning of all elements. If all HTML authors would respect this, we could build and use user-agents that make perfect use of the markup. In reality though, authors might (mis-)use
nav
to "devalue" boilerplate content ☺, which would force all consuming user-agents to forget about the special meaning ofnav
(because it might contain other, non-navigational content, that could be important for their use case).