Start learning with our library of video tutorials taught by experts. Get started

HTML5: Structure, Syntax, and Semantics

Building navigation


From:

HTML5: Structure, Syntax, and Semantics

with James Williamson

Video: Building navigation

It's time to finish our page's main header section by adding our page navigation. Now, we already have the nav element, so all we really need to do is go in and add our sites menu. Now, for the most part, how we code menus or related links really hasn't changed at all. So, if you're familiar with the process in HTML 4, you are going to be comfortable with it here. So, we are going to be working in the trails.htm file, and this one can be found in 04_08 folder. Now, one of the things that I want to point out from earlier when we looked at our navigation, if you remember when we looked at the document outline, it basically said NAV Untitled section, or Untitled NAV.
Expand all | Collapse all
  1. 2m 20s
    1. Welcome
      48s
    2. Using the exercise files
      1m 32s
  2. 19m 7s
    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 53s
  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

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
HTML5: Structure, Syntax, and Semantics
4h 34m Beginner May 31, 2011

Viewers: in countries Watching now:

Gain a deeper understanding of HTML5 and learn how to create richer, more meaningful web pages with structural tags and descriptive attributes. In this course, author James Williamson presents an overview of HTML5 and its development, defines the new tags and attributes, and discusses how browsers parse and display HTML5 content. The course also includes step-by-step instructions for constructing an HTML5 document with a header and footer, navigation, content groups, and formatting.

Topics include:
  • Defining basic elements
  • Exploring the content model
  • Creating document sections
  • Using hgroup to override sectioning
  • Using the proper nesting structure
  • Choosing the right structural element
  • Using class and ID attributes
  • Building navigation
  • Grouping content with asides
  • Using divs in HTML5
  • Creating block level links
  • Defining link relationships
  • Understanding current browser support
  • Adding support for elements in older browsers
Subjects:
Developer Web Web Design Web Foundations Programming Languages Web Development
Software:
HTML
Author:
James Williamson

Building navigation

It's time to finish our page's main header section by adding our page navigation. Now, we already have the nav element, so all we really need to do is go in and add our sites menu. Now, for the most part, how we code menus or related links really hasn't changed at all. So, if you're familiar with the process in HTML 4, you are going to be comfortable with it here. So, we are going to be working in the trails.htm file, and this one can be found in 04_08 folder. Now, one of the things that I want to point out from earlier when we looked at our navigation, if you remember when we looked at the document outline, it basically said NAV Untitled section, or Untitled NAV.

So, we want to correct that. So, one of the first things I am going to do is we will go into the nav element which is found right here in the header. And I am just going to hit Return so that I have got some vertical lines to work with here. And the first thing I am going to do inside my nav element is I am going to identify the section with a heading. So I am going to do an h2, and I am just going to say 'Main page navigation'. Now, obviously that's not something I want to show up in my final document. I don't want that up on the screen, so I am going to use CSS to hide this. So, all this is really doing for us, structurally, is identifying, or giving a title, if you will, to this particular section.

Now, I am going to talk more about the need for this particular heading. So, just as we have done in the past, I am going to go ahead and create an unordered list to group all of our links. That's quite common practice. I am sure it's probably something that you may have done before. Inside the unordered list, I am going to do our first list item, and inside that, I will do our first link. So, we will do an anchor tag, and we will do an href attribute, and this is going to go to the external Explore California site. So, the way that this site is working, the Trail Guide is sort of a sister site, if you will, a brand site to sub-brand of Explore California.

So, we are going to go to explorecalifornia.org, and we are going to go ahead and give that a title, and our title is going to be Visit Explore California. All right, excellent! Now, inside this, the link text is just going to say, 'explore california'. So, that's actually going to the link. I am going to do it in all lowercase, just like cool kids do. I am going to close my link, close my list item, and there is our first menu item. Now, what I am going to do at this point is I am just going to copy this, and then each time I needed a new link, I am just going to paste it and change the relevant data. I like to type as little as possible.

All right, so on the next line, I am going to change the link from explorecalifornia to a document-relative link. In this case, it's going to be trails.htm, and of course, that's the page that we are on, right? And the title of this one is going to be Trail Reviews, and that is also going to be the text for the link, so it will say trail reviews as well. And one of the things I want to do here is I am going to put a class here. So, we are going to use our first class in the structure of a page. I am going to assign that a class of current to let people know it's the current page that we are on, and also stylistically, it's going to change how the link looks on our page.

Okay, so I am going to go down to our next link. I am going to paste that there, and the address for our next link is going to be news.htm. The title will be Trail News and that is also going to be the link text, trail news. We have just got a couple more links to do. The next link is going to be to resources.htm, and the title for that is going to be Trail Resources, and the link will also say resources. Very cool! One more link left to do, and this one is also going to go outside to the Explore California site.

It's going to go to a specific page, in this case tours.htm, and the title for that will be Biking Tours. And we will just go ahead and change the link text to tours, and then I am going to go ahead and save that. So, what I am going to do now is I am going to preview this in a browser, and I want to check the document outline. I want to see if our heading is actually giving the section now a title. So, I am previewing it in the browser, and I am just going to go up and check the outline. And again, Main page navigation is now listed right there in the outline, which is perfect.

That's exactly what we want. Now, I want to go back into the page structure for just a moment and talk about this. For the most part, everything in HTML5 works fantastic, but there are certain things that I kind of wish would change. This is one of them. So if you have a new section of content and that section is started by any of the sectioning elements--nav, article, aside, section-- you have to have a heading at the top of it if you want that section to be titled. Now, in this case, we are forced to put an h2 or some type of a heading inside a nav element that really doesn't need it.

So, we are not going to display that visually. We are going to have to use CSS to hide that so that adds this little burden when we go and style this. But in order for this to be machine readable or to have an assisted device like a screen reader come in say, okay, this is a nav, main page navigation, I need to have this setting in here. I kind of wish that you could identify a section by the ID attribute or maybe a title attribute, but that is not the way that spec works. It's not how the outline algorithm works. So, we are forced to put this content in. It's not non-semantic. I mean, it makes sense, but again, it's a little bit of overkill.

Now, in my mind, it doesn't necessarily have to be there. Now, I also want to point out that nav elements can contain more than just links. You can put whatever structure you want inside of a nav element. So, in this case, we have an unordered list and a heading 2, but you could have paragraphs; you could have really whatever structure you need. But I tend to take the philosophy that you really ought to have as little as possible inside a nav element. It's whatever you need to represent that particular grouping of links and really nothing else. Now, remember the definition for your nav element. It really needs to be a main piece of either site navigation or page navigation, and it's something that you want exposed in the outline, something that you want accessible to assistive devices or other machine-readable devices that are going to come in and look at your code.

So, in this case, our navigation is finished. It's ready to go. We wrapped our main navigation in the header, so we located it in the header, and doing that allows us to establish a structure that's going to work across our entire site. Now, it's worth mentioning here that even though no other link grouping on our page met the criteria for a nav element, it's really quite common of the page structures. Keep in mind that things like blog posts, while blogs typically have a blog roll contained in the sidebar in a list of archived or categorized posts, that would be perfect for nav element. Now, other sites might have secondary site navigation that would be suitable for nav element.

As always, it's really is a judgment call. Now, speaking of judgment calls, remember that while the HTML5 spec points out that links contained in the footer don't often require a nav-- in the spec, it just basically says hey, if there is a grouping of navigation links in the footer, usually the footer is sufficient for that-- you don't need a nav element. But I am going to advice you a little bit differently on that. I want you to consider strongly whether those links meet the criteria for either being exposed in the outline, meaning you want them show up, or more importantly to me, exposed to assistive technology such as screen readers and things like that.

If the answer for any of those links that you might find in your footer is yes, then I really recommend using a nav in those instances, regardless of what the spec actually recommends.

There are currently no FAQs about HTML5: Structure, Syntax, and Semantics.

Share a link to this course
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.
Upgrade now


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.

Upgrade now

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
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

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