Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

The nav element

From: HTML5: Structure, Syntax, and Semantics

Video: The nav element

The next element I want to introduce you to is the nav element. Now, as the name suggests, the nav element allows you to group and identify site navigation. Let's go to the spec and take a closer look at it. Now again, remember, we are looking at the HTML5 specification, the author view that the W3C provides us, and from here on out, instead of finding the table of contents, I am just going to jump directly to that section. So, table of contents is pretty easy to find your way around. Just go ahead and keep spec open throughout this title and just search through and find the nav element.

The nav element

The next element I want to introduce you to is the nav element. Now, as the name suggests, the nav element allows you to group and identify site navigation. Let's go to the spec and take a closer look at it. Now again, remember, we are looking at the HTML5 specification, the author view that the W3C provides us, and from here on out, instead of finding the table of contents, I am just going to jump directly to that section. So, table of contents is pretty easy to find your way around. Just go ahead and keep spec open throughout this title and just search through and find the nav element.

So here we are in the Sections area looking at the nav element. Again, Category content, it's both Flow and Sectioning content, so go ahead and file that away for a little bit later when we talk about the difference between the different content models. Notice that it expects Flow content inside of it, but there are no real limitations here. All right, so let's take a look at the description. So the nav element represents a section of a page that links to other pages or to parts within the page, a section with navigational links essentially. There are really important notes that follow this; you would definitely want to read these. So notice the first note here that says, "Not all groups of links on a page need to be in a nav element." So let's take a look at some of the criteria for when you should consider putting something inside of a nav element.

Notice that it says it's primarily intended for sections that consist of major navigational blocks. Here's something interesting. In particular, it's common for footers --footer elements, which we're going to cover a little bit later--to have a short list of links to various pages for a site. And it says, a lot of times the footer element alone is sufficient for such cases. So, that's kind of interesting. So, essentially it's telling us major navigation blocks, maybe if you've got some links in the footers, maybe yes maybe no, but now the second note adds even more clarity to it. I am going to scroll down a little bit, so we can see this one. "User agents (such as screen readers) that are targeted at users who can benefit from navigational information being omitted in initial rendering," so skipping a nav, if you will, "or who can benefit from navigation information being immediately available, can use this element as a way to determine what content on the page to initially skip and or provide on request." Now those two things, when you put them together, really gives you a criteria for using the nav element or not.

So, is it a major navigation block? If assistive technologies, such as a screen reader, were accessing your page, would you want those links presented as a major navigational unit for something to either skip over or to be accessed right away? If the answers to those were yes, then the nav element is probably appropriate. But if it's not something that you'd want to experienced right away or that you would want presented as separate element, the nav element is probably not appropriate. Now again, let's take a look at some of the examples I have used here. Here we have some markup where we have a whole list of links here, going to news, blogs, and forums, but that's not considered in this case a major navigational block.

If you look just underneath that where the navigation is being identified, that's linking to all of the articles and what's going on today, success stories--that is encased in the nav. So really, this example crystallizes, more than anything else, that the use of the nav element is a judgment call. It is up to you as the web author to determine whether those list of links, those blocks of links, fall under the category of being a major list of navigational items. I also want to point out that the nav element can contain more than just links. Notice here, for example, there's an h1 tag inside of an unordered list.

You've got your list of links, and it could even wrap things like paragraphs. So if I scroll down a little bit further to one of these sort of the bottom examples, you can see the nav element here. It's containing a lot of things. Here is the heading1 tag, paragraphs, a whole section of content here being encased here within the nav element. So now that we know a little bit more about the nav element, let's switch back to our page and put it to use. So what we are looking at here is the html5.htm document open up from 02_04 folder, and really it's just an extension of what we were doing in the previous exercise.

Again, if I look through my links on the page, I really have only one big block of links. So I do have some links down here on the bottom for monthly specials, and these are linking to different packages that we are trying to promote to people. But if we think about that, that's not really a list of major navigation site navigation, so that probably doesn't meet the criteria. However, if I go up here where I have a div whose id is actually navigation--and this is my main site navigation-- this one certainly fits that criteria. So I am just going to replace the existing div tag with the nav element, and again, don't forget to do the closing tag.

So I am going to covert both the opening div tag and the closing div tag, two nav tags, and save the file. Like most of the new structural elements that we are going to learn, many times the trick to the nav element is going to be knowing when to use it. Just remember what the spec suggests, that it's for sections that consist of major navigational blocks, for sites, or blocks of navigation within the current page. Now I like to look at it this way. If I would want a user agent, especially assistive technology, to identify these links, so it could hide them, skip them, or highlight them, to facilitate reading a navigation, well, then a nav element is probably appropriate.

Show transcript

This video is part of

Image for HTML5: Structure, Syntax, and Semantics
HTML5: Structure, Syntax, and Semantics

46 video lessons · 35887 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 20s
    1. Welcome
      48s
    2. Using the exercise files
      1m 32s
  2. 18m 41s
    1. A brief overview of HTML5
      3m 57s
    2. What's in the HTML5 specification?
      8m 17s
    3. Why do we need new structural elements?
      6m 27s
  3. 50m 33s
    1. Defining HTML5 documents
      5m 5s
    2. HTML5 syntax
      9m 14s
    3. The header element
      5m 22s
    4. The nav element
      4m 55s
    5. The section element
      4m 51s
    6. The article element
      4m 48s
    7. The aside element
      4m 13s
    8. The footer element
      4m 17s
    9. Content model overview
      7m 48s
  4. 35m 28s
    1. Understanding the outline algorithm
      3m 17s
    2. Creating document sections
      8m 25s
    3. Using headings properly
      9m 1s
    4. Using hgroup to override sectioning
      4m 17s
    5. Properly nesting structure
      7m 17s
    6. Sectioning roots
      3m 11s
  5. 58m 30s
    1. Organizing content
      4m 41s
    2. Planning document structure
      5m 47s
    3. Choosing the right structural element
      4m 43s
    4. Checking document outlines
      5m 27s
    5. Coding initial page structure
      5m 28s
    6. Using class and ID attributes
      5m 31s
    7. Structuring headers
      13m 13s
    8. Building navigation
      7m 1s
    9. Structuring footers
      6m 39s
  6. 1h 27m
    1. Working with figure and figcaption
      7m 12s
    2. Grouping content with asides
      3m 46s
    3. Using divs in HTML5
      5m 0s
    4. Working with lists in HTML5
      7m 10s
    5. The return of bold and italic
      5m 52s
    6. Citing works semantically
      6m 32s
    7. Using the address element
      5m 24s
    8. Using the small element
      4m 24s
    9. Using the mark element
      5m 16s
    10. Working with date and time
      11m 55s
    11. Creating block-level links
      8m 53s
    12. Understanding link relationships
      9m 28s
    13. Defining link relationships
      6m 23s
  7. 17m 22s
    1. Current browser support
      7m 38s
    2. Ensuring block-level display
      4m 3s
    3. Adding support for elements in older browsers
      5m 41s
  8. 3m 46s
    1. Additional Resources
      3m 46s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed HTML5: Structure, Syntax, and Semantics.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.