Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the HTML5 <nav> element be used to group links that filter or reorder main content?

Our site has two primary navigation links to two completely different pages. Something like this:

<section>
    <header>
        <nav>
            <ul>
                <li><a href="link1.html">Link 1</a></li>
                <li><a href="link2.html">Link 2</a></li>
            </ul>
        </nav>
    </header>
</section>

On one of the pages, we also have a filtering component made up of a list of links that uses Ajax to change the result set listed in the main content area (similar to how kayak.com filters their flight options in real time as you adjust sliders, click checkboxes, etc.)

My question is, should that group of filtering links be wrapped in a <nav> element?

It would look like this:

<section>
    <nav>
        <ul>
            <li><a href="#filter1">Filter 1</a></li>
            <li><a href="#filter2">Filter 2</a></li>
            <li><a href="#filter3">Filter 3</a></li>
            <li><a href="#filter4">Filter 4</a></li>
            <li><a href="#filter5">Filter 5</a></li>
        </ul>
    </nav>
</section>

The reason for my confusion is that the spec is not clear as to whether materially changing the content of the page via a method such as filtering constitutes "primary navigation". Also, I'm not sure if having two nav elements on the page like this would be semantically confusing from an accessibility standpoint.

like image 648
Dennis Plucinik Avatar asked Apr 25 '12 15:04

Dennis Plucinik


People also ask

What is the use of NAV element in HTML?

The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.

How do I group all navigation links in HTML?

The objective of this technique is to group navigation links using the HTML5 nav element. The nav element is one of several sectioning elements in HTML5. Use of this markup can make groups of links easier to locate and skip past by users of assistive technology such as screen readers.

Which tag is used to group all navigation links?

The <nav> tag defines a set of navigation links.

Can you have two nav elements in HTML?

Nav can be used multiple times on a page in HTML5.


1 Answers

You could, but it's not semantically correct. I'd go for a command tag here, because you're not navigating the content, you're giving the command to show/hide certain content based on some criteria.

like image 99
bigblind Avatar answered Nov 15 '22 00:11

bigblind