HTML5: Putting site navigation <nav> links at <header>

This entry is part 7 of 34 in the series HTML5

HTML5 also introduces site navigation element <nav>.

We can put <nav> at the header so that they are shown on the top of the page.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML 5</title>
    <style>
        nav li {
            display: inline;
        }
    </style>
</head>
<body>

<header>
    <hgroup>
        <h1>Great Music News</h1>

        <h3>Latest news on Rock, Metal and Pop music!</h3>
    </hgroup>
    <nav>
        <ul>
            <li><a href='#'>Home</a></li>
            <li><a href='#'>British Pop</a></li>
            <li><a href='#'>Rock</a></li>
            <li><a href='#'>Country</a></li>
            <li><a href='#'>About</a></li>
            <li><a href='#'>Contact</a></li>
        </ul>
    </nav>
</header>

</body>
</html>

Note that we have styled the navigation links to be inline using display: inline.

 

 

Series Navigation<< HTML5: Using the <header> element for site header
HTML5: Multiple <header> on one page >>