Watching:

Solution: Structuring navigation


show more Solution: Structuring navigation provides you with in-depth training on Developer. Taught by James Williamson as part of the CSS: Styling Navigation show less
please wait ...

Solution: Structuring navigation

Let's take a look at the finished files from our structuring navigation lab and then compare them to your solution. Keep in mind that structuring HTML content often relies heavily on personal preferences, so don't automatically assume that your file is wrong if it doesn't match mine. Simply listen to why I structured the content the way that I did and then re-examine your content based on my reasoning. Deciding to keep it the way that you did it is an entirely viable option if you feel strongly about why you did something a certain way.

So, this time I have the index.htm open from the 01_05/finished_files folder, and I am just going to go through each of the steps and kind of show you how I solve the problem, and then you can sort of compare that to yours. So the first thing we wanted to do was to add a Skip navigation link below the page's main heading. So if I scroll down, I can see that just below the h1 I've added this anchor element here with the text of skip to main content, so it has actual content inside the skip link. I'm linking down to the main content region so I am using the ID for the main article to do that.

Now if you went down to one of those initial sections and just skipped the navigation, that's fine, there is nothing wrong. I just chose to go to the main content instead. I also gave it a title so that it's a little bit more descriptive, skip to main page content. And then I did something that you probably didn't do, which is I applied this class right here, class attribute of skip to it, and I just did that for stylistic purposes. It's pretty much the way I handle all of my skip navigations if I want to hide them or change them stylistically, I usually apply a class of skip to it, and that allows me to style that particular link differently than any of the other links on my page.

The next task was to properly structure the menu below this, and if I scroll down just a little bit, I can see that what I did was I took the links, and I sort of wrapped them in an unordered list so that they're now organized and structured as relating to each other within that list. And I also wrapped the list in a nav element because they are the site's main navigation, so it makes sense as this is an HTML file, that they are wrapped inside of a nav element. Now I did a couple of things here that were optional.

I added the role of navigation. Some of you guys may have done that based upon the accessibility movie that we covered earlier in the chapter, but I also gave it an ID, and I gave it an ID of page nav, and I doubt very many of you have exactly the same thing going on there. Now the reason that I do that is I like to take all main sections of content and identify it with an ID attribute. To me, those are unique sections of content so I like to identify them as such, and I like the ID to be a little bit meaningful in terms of what it's actually representing.

Now the next step was to go down to these two sections, the student spotlight and the current show, and to take the text inside there that said more info and change that in some way so that was a little bit more descriptive. So I really, really doubt that you guys have exactly what I have here since, you know, I left that totally up to your interpretation. So for Student Spotlight, I really didn't do anything fancy. I just did student spotlight. And at this point when somebody clicks on it, if a screen reader was reading this, they would read through that, and then they would say link Student Spotlight and they can infer from that, that they are actually going to read more about the student profile.

Below that we have our Current Show, and I just changed that text to see our current show. You have to be really careful. A lot of times when somebody uses text like more info or click here it's because they don't have a lot of room. In this case, if I looked at the way our page looked in the finished file before we did this, when I hover over this you can see how the more info is being displayed. So we do have a line here which gives us a little bit of room for the new text that we've got in place, but oftentimes that might be really, really small. So sometimes coming up with descriptive text that fits into the space that you have for it is not the easiest thing in the world to do.

Now finally, we were to go down to the footer and to see if it would benefit from any additional structuring. So I am going to scroll down, so I'll find my footer, which in this case is now on about line 103. Now, you'll notice that I actually did add a little bit more structure to it, and I did that through the use of a nav element. Now, since this is actually sectioned off into different areas, you have the About Roux Academy, you have Admissions & Programs, you have Student Resources, I could see you guys thinking, okay, well, it is main navigation, so maybe I need a nav element and then actually using three of them, since we have three different sections here about Roux Academy.

And that's really a judgment call. And my judgment here I am looking at these groups of links, and I am saying well they are really all related because there are inter-site links that go to pages within the site and they have three different sections to them, and I have section elements basically performing that role of sectioning them all off. When you look at them as a whole, though, they are all one big group of navigational elements, and that's why I used the nav tag only once around all of those different sections. Now I also used the ARIA role of navigation, and I gave it a class of footer nav.

I doubt you use a class of footerNav, I did that for stylistic purposes. That's obviously something that was just optional, but you'll see it in the finished version of the site, so I want to make sure it was here as well. And of course, the role of navigation is optional, but it's nice for accessibility standards. Now you might be wondering, well, okay, you-- in the previous exercise within the chapter you had links in the footer and you didn't use a nav, and here you have links in the footer, and you did use a nav, why? What's the difference? Well, as I mentioned, it really is a judgment call. I look at this footer, and I see a lot going on here.

Not only do I have all of these links, but after that I have links that go to things like privacy statements, disclosures, student outcomes, things like that. They're just within a paragraph. They are not really navigational structures. So when I look at these unordered lists, these menus that I have for each of these sections, that I have a footer here that's a lot more complex, there is a lot more information going on within the footer than just the links themselves. So the footer tag, or the footer element, really doesn't serve as the organizational element for all of the content inside of it.

And since those links are links within the site, and since they do link to main navigational areas within the site, to me, this serves as maybe even a more comprehensive list of links than the main navigation itself. Those are the things that led to my determination that the nav element should be used. So again, you know, using the nav here or leaving it off totally, a personal preference if you left it off, that's not necessarily the wrong call. It could have been exactly the way that you wanted to express the structure of the page. Now the thing I really want you to take away from this lab is it's really easy for people to lose sight of the fact that writing well- formed semantic HTML does have uses outside of you know making it nicer for user agents and easier to index and parse.

It actually makes it a lot easier for you when you're writing your styles. It makes it easier to write efficient styles. Now this is especially true for navigation. So, pay particular attention to how you plan and structure your links within your sites.

Solution: Structuring navigation
Video duration: 7m 7s 5h 14m Beginner

Viewers:

Solution: Structuring navigation provides you with in-depth training on Developer. Taught by James Williamson as part of the CSS: Styling Navigation

Subjects:
Developer Web
Software:
CSS
Author:
please wait ...