Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 NAV vs. HEADER ordering

In one of the sections of my site, my NAV is above my header.

<nav> 
  <ul>
    <li><a href="#">Service</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Subscribe via RSS</a></li>
</ul>
</nav>

<header>
  <h1>Page title</h1>
</header>

Is it valid or acceptable to use a NAV before the header? Or is there a rule that NAV needs to be after the HEADER?

Will this affect SEO or page rank in any way?

like image 361
Tech4Wilco Avatar asked Oct 04 '11 13:10

Tech4Wilco


People also ask

Should I use NAV or header?

The <nav> tag is used inside the <header> tag . This may happen if <nav> is very small and if the content of <nav> tag is used to identify the different web content. In such cases, the <nav> is usually taken inside of the <header> tag.

What is the difference between NAV and header in HTML?

The header contains introductory information about the document. The nav is a menu that links to other documents.

What's the difference between header and NAV?

By using a <header> tag, our code becomes easier to read. It is much easier to identify what is inside of the <h1> 's parent tags, as opposed to a <div> tag which would provide no details as to what was inside of the tag. A <nav> is used to define a block of navigation links such as menus and tables of contents.

Does NAV need a heading?

The nav element is a sectioning element, much like body, article, section and aside. Every section is expected, though not required, to have a heading.


3 Answers

I don't see why not. The nav is global navigation and therefore not specific to that particular page. I think it makes sense that the nav would be 'outside' the rest of the page content. If the nav was for navigating around that particular page then it should come below.

If, however, you had the name of the website in the <header> and <h1> rather than the name of the page then I suppose it should appear below the header.

Edit

Regarding your edit about SEO, you want your keywords to be as close to the top as possible and your title should contain the best and most relevant keywords so it should ideally go at the top. However, if your nav is as long as the code you have provided then I think the effect of switching them would be negligible. If your nav actually consists of numerous nested lists for dynamic dropdown purposes then I would certainly consider switching them around.

like image 115
punkrockbuddyholly Avatar answered Oct 29 '22 10:10

punkrockbuddyholly


You can have them in whatever order you like. It's also valid to have multiple occurences of those elements:

<body>
    <header>
        Site header
    </header>
    <nav>
        Site nav
    </nav>
    <article>
        <header>
            Article header
        </header>
        <p>Article content</p>
    </article>
</body>
like image 31
John Keyes Avatar answered Oct 29 '22 10:10

John Keyes


That's fine, though a little weird – why not put them the correct order in the HTML, and then use CSS to move things around. That is of course, the whole point of the CSS/HTML separation.

like image 23
Rich Bradshaw Avatar answered Oct 29 '22 12:10

Rich Bradshaw