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

Properly nesting structure

From: HTML5: Structure, Syntax, and Semantics

Video: Properly nesting structure

For the most part, once you learn the basics of the outline algorithm, structuring your documents properly requires only a minimal amount of planning. There are times, however, that certain nesting requirements, or element types, makes giving the proper outline rather tricky. Now, let's take a look at some of the issues that you need to consider when structuring more complex documents. So here I am again at the HTML5 Outliner, but I have cheated a little bit. Let me show you. So if I scroll down into this coding section, you can see that I have already sort of entered some of code in there. Now if you want to do this along with me, what I am going to do is scroll down so you can see the code I have added, and you can pause the video and go ahead and code that.

Properly nesting structure

For the most part, once you learn the basics of the outline algorithm, structuring your documents properly requires only a minimal amount of planning. There are times, however, that certain nesting requirements, or element types, makes giving the proper outline rather tricky. Now, let's take a look at some of the issues that you need to consider when structuring more complex documents. So here I am again at the HTML5 Outliner, but I have cheated a little bit. Let me show you. So if I scroll down into this coding section, you can see that I have already sort of entered some of code in there. Now if you want to do this along with me, what I am going to do is scroll down so you can see the code I have added, and you can pause the video and go ahead and code that.

I just think that probably watching the code is pretty boring. I am going to scroll down a little bit, and here's what I added to it, and this is all of the code that I have added. So go ahead and pause your video, type this in, and then we'll start back again. Okay, so let's a take a closer look at the actual structure here. So we have our main page title, which is Explore California, and inside that, we have a section. So inside the Our Tours section, we have an article that includes Our Tour Reviews, and the Tour Reviews have currently two tours that we have reviews listed for.

We have Cycle California and Backpack Cali, and each of them have just a couple of tours added. Now, if I outline this, you can see that I get the document structure that I'm anticipating. We have the Explore California as the title of the page, the Our Tours, which is the section, Tour Reviews is the article, and then it has individual sections inside of it: Cycle California and Backpack Cali. Now you can kind of see the strategy I am using for my headings. Anytime I have a new section, such as article here, I am starting off with an h2 tag. So my section that's nested inside here gets an h2, and inside the article, I get an h2.

Now essentially, after that I am going just use the regular heading hierarchy to nest my sections. Now, you can see I am already on h4, so if this was going to be a really complex page structure, I may need to rethink this, because my headings only go to h6. All is well and good at the moment, but what if somebody comes along, my client, and says, "Hey, you know we've got this really urgent note that we want to pass along about a charity," for example, "that's going to help update or save endangered hiking trails"? In their desire to get the right people read it, they want to place this note right here with the Backpack Cali reviews, which kind of makes sense. But if you think about this, it's not exactly a tour review, so it's just sort of related content.

Now, we know from some of the tags that we studied or talked about earlier that one of the great semantic tags that we have now is an aside tag, which allows us to basically describe tangentially related content, and that's what I am going to use here. So I am going to inside the h3, and tabs don't really work here, so I am just going to hit the spacebar to sort of nest this, essentially. And what I am going to do is right here at h3, I am going to go in and create an aside tag. Inside the aside tag, I am just going to have a heading 2. Remember, the aside tag is sectioning content, so I am going to create a new section. So I am going to do an h2 and I am just going to going to say, "Help save our trails." It would be a more complex structure than that.

We would also have some paragraphs and maybe even a form or something like that for the people to fill out, but then I am just going to close the aside tag. So again, notice the location of the aside tag. It is nested inside of the article. It comes directly after the Backpack Cali. So if go ahead and outline this, something bad just happened to my document outline. Notice now that Hiking Big Sur, Ojai Hills, LA Urban Hikes, they're all actually on the same level as Backpack Cali, whereas, really, I just want Help Save our Trails to sort of interrupt the document flow, but I want to go right back to it afterwards.

Well, maybe the heading is at fault. So if I go back, I can see that we sort of had an h2 there, but what if I go down to say an h4? That would put this heading on the same level as these guys, right? If I outline that, it doesn't work either, and it doesn't work because remember, anytime sectioning content is encountered, a new section is created and the top heading in that section is used to title it. So the level of the heading in this case doesn't really matter. So the problem here is, by interrupting the sequence with the sectional content, we have separated the ranking values of the headings, right? So remember, headings create implicit sections, and then subsections based on rank, but they have to be sequential.

So once they're interrupted the way we're interrupting them here, essentially all these sections remain at the same level in the outline because they are just reestablishing them. Because these are all h4s, they are reestablishing a new section after the aside, but because these are all h4s, they remain on the same level. So the heading that we used inside the aside obviously doesn't matter. So if we wanted to reestablish that flow, maybe the aside isn't the element to use. What if we use a div? Remember, divs are just generic sectioning content. So let's try a div there. Okay, now I am back to getting what I want. Help Save our Trails is inside Backpack Cali, along with the other guys.

You know, that sort of brings up a bigger problem. I want to use the aside element. You know the aside element is supposed to be for tangentially related content. It describes meaning. It helps, gives meaning to the content. The div tag doesn't do that at all, so the aside element is really what I need there. So I am going to go back to aside element. And I am even going to go back and do an h2, because since it's a new section, you always start new sections using the ranking that we are doing with an h2. All right, so what's the problem? So the problem isn't so much with the aside itself. It really isn't.

It's with trusting the headings to create implicit sections. Now, this initially may create much cleaner code, because we can just do our headings h2, h3, h4. It does lack the flexibility that we need if we need to interject new sectioning content into our layout. So we are going to modify our code a little bit so that we can say, have our cake and eat it at the same time. All right, so I am going to go back at the Tour Reviews. Now remember, inside Tour Reviews, we have essentially two sections: Cycle California and Backpack Cali. So I am going to just do that.

I am going to go ahead and wrap those in section tags. So just inside Tour Reviews, I am going to enter my first section. And since that section is Cycle California, we'll go ahead and enclose that in a section tag. And then we're going to do the exact same thing for Backpack Cali. So now instead of letting the headings form implicit sections, we're being explicit in the sections. We're taking control of that, essentially. And then after my LA Urban Hikes, I will go ahead and close that section. Just to make things look a little neater, I will go ahead and add some spaces there to nest that as well.

So notice that now we have, not implicit sections being created by our headings, but we have a very explicit section that we have created. And so, because of this now, if I outline it, I get exactly what I'm looking for, because we have an individual section here and now an individual section here, and the aside is not sort of breaking those implicit sections being created. So by enclosing both the tours and the reviews in a section element, not only do we logically organize the content, but we are explicitly creating the structure that we need for the Tour Reviews article.

Now that's not to say that using headings to create implicit sections is wrong. I certainly agree that in many cases less is more, and you don't want to add additional structure just for the sake of structure if you don't have to. I hope this illustrates for you how important it is to not only put a lot of thought into what your document outline should look like before you begin coding, but also what structures are going to be required to achieve the proper outline based on the complexity of the content or additions to it later on down the line.

Show transcript

This video is part of

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

46 video lessons · 35917 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.