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

HTML5 First Look

Structuring top-level elements


From:

HTML5 First Look

with James Williamson

Video: Structuring top-level elements

Let's put some of what we've learned about the new structuring and semantic capabilities of HTML5 into practice by converting a page using older HTML 4 structuring into a new semantic HTML5 layout. We'll start by focusing on the top-level structural elements first: the header, main content, and in the footer regions. So here I have the trails.htm file open from the 04_02 folder, and I just want to go over the structure a little bit before we go in and convert some of these tags.
Expand all | Collapse all
  1. 3m 56s
    1. Welcome
      1m 1s
    2. Using the exercise files
      1m 50s
    3. Who is this course for?
      1m 5s
  2. 21m 12s
    1. Exploring prior standards
      4m 26s
    2. Why do we need HTML5?
      3m 32s
    3. HTML5 timeline
      4m 24s
    4. Current HTML5 support
      4m 25s
    5. What HTML5 is (and what it isn't)
      4m 25s
  3. 27m 49s
    1. HTML5 vs. HTML4
      3m 25s
    2. New structural tags
      6m 1s
    3. New content tags
      4m 7s
    4. New application-focused tags
      5m 32s
    5. Deprecated elements
      4m 28s
    6. API overview
      4m 16s
  4. 22m 29s
    1. Content models
      5m 33s
    2. Understanding the outline algorithm
      3m 21s
    3. The role of ‹div› tags
      4m 20s
    4. Using ID and class attributes
      2m 6s
    5. DOCTYPE declarations
      4m 16s
    6. Character encoding
      2m 53s
  5. 41m 27s
    1. Basic page structure
      3m 40s
    2. Structuring top-level elements
      7m 30s
    3. Structuring interior content
      8m 42s
    4. Building headers
      9m 11s
    5. Checking document outlines
      5m 46s
    6. Ensuring cross-browser structure
      6m 38s
  6. 27m 53s
    1. New input types
      5m 57s
    2. Setting form autofocus
      2m 53s
    3. Using placeholder data
      4m 4s
    4. Marking required fields
      3m 24s
    5. Working with number inputs
      5m 49s
    6. Using date pickers
      5m 46s
  7. 1h 1m
    1. Canvas overview
      6m 21s
    2. Adding canvas content
      8m 58s
    3. Drawing in the canvas environment
      12m 9s
    4. Drag-and-drop API overview
      6m 18s
    5. Offline applications overview
      7m 11s
    6. Video overview
      5m 45s
    7. Encoding video
      8m 23s
    8. Adding video
      5m 58s
  8. 57m 33s
    1. Geolocation API overview
      5m 50s
    2. Web storage API overview
      5m 40s
    3. WebSockets overview
      4m 16s
    4. CSS3 overview
      6m 38s
    5. Enhancing typography with CSS3
      7m 42s
    6. Using @font-face
      7m 11s
    7. Styling HTML5 with CSS3
      10m 23s
    8. Using CSS3 transitions
      9m 53s
  9. 5m 6s
    1. Final thoughts
      3m 49s
    2. Goodbye
      1m 17s

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 First Look
4h 28m Beginner Aug 23, 2010

Viewers: in countries Watching now:

In HTML5 First Look, author James Williamson introduces the newest HTML specification, providing a high-level overview of HTML5 in its current state, how it differs from HTML 4, the current level of support in various browsers and mobile devices, and how the specification might evolve in the future. Exercise files accompany the course.

Topics include:
  • Understanding the history of HTML5
  • Using new tags
  • Understanding HTML5 semantics
  • Coding ID and class attributes in HTML5
  • Structuring documents
  • Building forms
  • Exploring HTML5 native APIs
  • Encoding and adding HTML5 video
  • Exploring associated technologies such as CSS3
Subjects:
Developer Web Web Design Web Development
Software:
HTML
Author:
James Williamson

Structuring top-level elements

Let's put some of what we've learned about the new structuring and semantic capabilities of HTML5 into practice by converting a page using older HTML 4 structuring into a new semantic HTML5 layout. We'll start by focusing on the top-level structural elements first: the header, main content, and in the footer regions. So here I have the trails.htm file open from the 04_02 folder, and I just want to go over the structure a little bit before we go in and convert some of these tags.

So looking through the code, we have a div with an id of wrapper. It's a pretty standard practice to go ahead and wrap all of your content in a div tag, so that stylistically you can do with it what you want. Inside that we have a div with an id of mainHeader that is representing the top heading content of our page. Just below that we have another div and this one has an id of trailInfo. So inside of this, we have our trail guide information for the trail that we're looking at, in this case the Northridge Loop. If I scroll down a little bit, I can see that just below that I have another div with an id of trailNews.

Inside that we have a section that features a promotional video and inside that we have another section that focuses on providing rider reviews. Then if I go down a little bit further, I can see at the very bottom of the page we have a div that is enclosing the footer content of our page. So really, those are our four main sections of the page. We have a header, we have our trailInfo, which is basically the actual trail guide that we're looking at, we have a related news section that's showing us some promotional stuff and allowing riders to publish their own reviews, and finally we just have the page footer information.

So that's the structure we're interested in representing with HTML5 structural tags, and we're going to tackle those top-level elements first. So the first thing I want to do is I'm just going to go ahead and delete this comment up here that says update based on HTML5. That is what we are doing now. So I'm going to go ahead and do that. The next thing I'm going to do is I'll go down and I'll tackle these regions one at a time, and we'll talk about which tag it makes sense to use in that particular area. Now, first, I want to focus on this header region. So we have an opening div tag on line 10 and we have a closing div tag on line 22.

Well, this is heading content and it really makes sense for all this heading content to sit within a header. So I'm going to replace the div tag by highlighting the div, and I'm just going to type in header. I'm going to do the same thing for the closing div tag down here on line 22. I'm going to change that closing div tag to a closing header tag. So now all of that content should be enclosed inside of the header tag. Now, you might have noticed that I did not replace the id, and that might have been one of your first instincts is just go ahead and get rid of the id, because we don't need to tell somebody that's header content right? Well, as you'll see as we continue to structure the page, this isn't the only header tag we're going to use.

So in order to identify this as the main header of the page and be able to target it for styling, we're going to leave that id there and we're going to leave all of our ids there actually. So once again, I'm going to go down and find the div with an id of trailInfo. Now, this one starts on line 23 and ends on line 58. So we've got to remember that it ends on line 58. So again here we need to decide which tag to use for this. Now, it would be tempting to use an article tag here, because this is the information of the Northridge Loop, which is the current trail that we're focusing on.

You might actually expect that content to be published somewhere else or to be repurposed or maybe even syndicated, but there are two pieces of a content that probably would not go with it. Notice, for example, that we have a headline here for Ojai Trails, talking about the region that we're looking at, and we has some navigation here that allows us to go back and look at all trails or their current region of trails that we're looking, which is Ojai. That probably we would not publish. So with that in mind, it really doesn't make sense to use an article tag here. However, I do want to use sectional content, because this is a region of the page that should show up as a discreet element of content within our outline.

So instead of using a div tag, what really makes sense here is a section tag. So I'm going to replace the div tag with the section tag and again, I want the id to remain id="trailInfo". I'm going to scroll all the way down to about line 58 or so, find the closing div tag, and again we're going to change that to a closing section tag. Okay. Now, let's scroll down a little bit more and on line 59 we have the div with an id of trailNews. Now, in most layouts you'd represent this as a sidebar, so it has a promotional video, it has some rider reviews, and this is very good content, very important content, but maybe not as important as the content we just restructured.

So in the case of that, we have to choose between a couple of different types of tags. Again, we could use an article tag if we were going to republish this as separate content, but there are many individual pieces inside the trailNews and I doubt that I'd want to publish it all out as one big element. So probably not an article tag. I could also use another section tag here. There would actually be nothing wrong with that, but I think what I'd rather use here, and I'll highlight the div tag here, is I'd rather use an aside tag. Now, the reason that I would rather use an aside tag here is because this is content that is related to the remaining content on the page, but it's not as important.

So it's not me saying that, hey, this content has an equal amount of importance as the content above it. It's saying that these two are related but that is secondary content. Now, within the outline, you won't notice the difference. They'll still be main level bullet points, but other user agents could infer that difference. So now I'm going to scroll down and find the closing div tag, which is right here on line 80, and I'm going to make sure that I'm closing the aside tag there as well. Now, there is one thing that I want to point out here.

Because this aside tag is not inside the previous section's content, it's not saying that this content is related to the previous section. It's saying that the content is related to all the content on the page. So that would be the header, the trailInfo, and trail guide, and the footer as well. So by leaving it sort of outside and not nesting inside of another tag, we're saying that this content relates to everything on the page. Finally, we need to choose what tag to use for the page footer. Just like the header, it doesn't really need to be its own discreet element within the outline.

So using a section tag or using an aside tag or an article tag really doesn't make sense here. As a matter of fact, there's a tag that is perfect for this, and that would be the footer tag. The footer tag makes sure that its not going to show up within the document outline and it allows us to basically tell any type of user agent that this content is basically the footer content for the entire page. Again, I'm going to leave the id there, so we can target this through styling, and so that it passes a little bit more information about exactly what this content is.

So I'm going to go ahead and save that, and the top-level elements on our page are restructured using these HTML5 tag. So our restructuring is well underway. So the main structural elements of the document have been identified and we're making sure to use tags that are appropriate to the document outline that we want to represent. In our next movie, we'll take the structuring a little bit further by structuring the interior contents of our page regions.

There are currently no FAQs about HTML5 First Look.

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 First Look.

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