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

Ensuring accessibility

From: CSS: Styling Navigation

Video: Ensuring accessibility

While writing valid semantic HTML is important, making sure that your content is accessible to everyone is just as important. Now thankfully those two things go hand in hand. So let's take a look at a few things that you can do to ensure the links on your sites are accessible. To do that I've opened up the accessible.htm file, which is found in the 01_02 directory. And the first thing I am going to do is open this page up in a browser. Because not only does it serve as our exercise files, but it also has all of the talking points that we're going to be using as we go through this exercise.

Ensuring accessibility

While writing valid semantic HTML is important, making sure that your content is accessible to everyone is just as important. Now thankfully those two things go hand in hand. So let's take a look at a few things that you can do to ensure the links on your sites are accessible. To do that I've opened up the accessible.htm file, which is found in the 01_02 directory. And the first thing I am going to do is open this page up in a browser. Because not only does it serve as our exercise files, but it also has all of the talking points that we're going to be using as we go through this exercise.

Now the first thing I want to talk about are these Skip navigation links. These have been around for a very, very long time, and there's a lot of sites out there that use these. But they've sort of become one of those things that people just sort of assume you know, so people just don't even cover Skip navigation and sometimes people don't find out about them until much later on down the line. Well, essentially, the tops of most pages are taking up with a lot of navigation. You know for especially, for complicated sites where you might have a lot of dropdown menus, you might be looking at dozens of links at the top of the page before somebody actually gets to the content.

For sighted users that's not a big deal, you know you can get to your dropdown menus, you can choose to ignore them if you want, you can twirl right down to the content, but for people using a screen reader they are a big deal. Imagine having to sit through and listen to every single one of the links in your navigation before you can even start to get to the content. So essentially what a Skip navigation link is it's a small link at the very top of the page that usually just sort of jumps down to the main content or someplace else on the page that you want to redirect a user, if they're skipping over the navigation.

In most cases, designers will use CSS to hide these Skip navigation links and so they are only visible to screen readers. Some other websites will them make them visible but only on a hover or something like that. So you've get a lot of flexibility when using the Skip navigation links. So I am going to switch back over the code, and we're just going to create one really quickly to show you guys how easy these are. So, no we don't have a lot, we don't have a huge menu at the top of the page here, but let's just say we don't want to make users have to listen to each one of these links every single time out. Well, right after this heading, right here, that's making links accessible, I am going to go ahead and create a new anchor tag, and this one, I'm just going to use a fragment identifier, I am going to say href and then #content.

Now what that's going to do is it's going to link on the page to any element that has the ID of content so that's just going to sort of jump, or if you will, skip over the navigation. Next thing I am going to do is go ahead and give it a title--now we're going to talk more about the title attribute in just a moment-- but I'm just going to say Skip to content, so it's a little informative there. And then inside the anchor element I am going to type in skip to content. Now this is important, I've seen a lot of designers out there do these Skip navigation links that don't have any content in them whatsoever. They assume well, since I am going to hide it with CSS I'll just go ahead and create an empty anchor element.

The problem with that is that most screen readers out there will ignore empty elements so you don't want to do that. All right, so if I go back to the browser and refresh that, now I can see I have a Skip to content link, when I click that nothing happens. And the reason nothing happens is because it's sort of a two-part process, we have to have an element on the page with this ID. So I am going to go down to the article, just below the header, and I am going to give it an ID of content. So if I save this and then go back into my browser and refresh the page, now when I click on this, it's going to jump right down to the content region.

So Skip navigation links are definitely something you want to have on your site especially if you have a lot of complicated navigation at the top of page. Now the next thing you want to do to ensure accessibility is using the title attribute. So we have the global title attribute that can go on multiple elements, in this case I am obviously referring to it on links, and essentially what it does is it just passes along some additional information about the links. Now a lot of browsers will show these as tool tips if you hover over them but the real benefit to them is obviously passing along additional information to people using screen readers and other assistive devices.

They are really easy to do, as a matter of fact we just did one, so I am going to go down to our menu here in the code, and I am just going to add a few titles here. Now they should be descriptive, but you don't want to go too long with the description. So for index, I am just going to give it a title attribute of homepage. So that's fairly descriptive, but it's not a really long sentence, you don't won't be reading out a lot of stuff here. For products, I am just going to go ahead and say our products, for blog I am going to go ahead and give it a title of read our blog. I generally try to keep it four words or under, but that's totally my preference, you can do kind of whatever you want to.

I'm going to do company info for about and then finally for contact, I'll do contact us. I'm going to go ahead and save that. Now visibly we're not really going to see a whole lot here. If I highlight over these now, you can see we get this little tooltip. But that's not really what they're for, they're more for passing along additional information about the links themselves. Now the next thing, it sounds kind of obvious, but make your link content meaningful. When screen readers read out a link, they read out the link itself and they say link, and then they read the contents of the link.

If the contents of the link consist of something like click here, what does that actually mean? You want to make sure that the text within the link actually says something. For example, notice that if I go a little bit further down the page here, I have the infamous click here text, and I also have this really long URL. If you include really long URLs like that within an active link, remember screen readers are going to read out that whole thing, and that's going to be rather annoying. So, I am going to go back and change those two things. So I am going to go back in the code, I am going to scroll all the way down to the code, and I am going to replace the whole click here text, I don't like that, I am going to highlight that, and I am going to give it a little bit more descriptive text, I am going to say explore the WAI-ARIA specification, and I just want that inside my link.

You want to go down here, and I see this really long URL written out, I don't want that either. So what I am going to do here is I am just going to get rid of the URL. I am going to get rid of the word at, and then I am just going to take the anchor element, and I am going to surround the text that it's referencing, absolutely nothing wrong with that. So now instead of having to write out that entirely long URL and then have screen readers read that, now, if we go back and take a look at this page, we can see that these links are much more descriptive.

We're now actually going to do this as part of the exercise, but I do want to point out that links should also be keyboard accessible. What that means is if you guys are building applications, a lot of times people will create a link on the page, that's not even really a link, they'll have like a div tag or a paragraph or a list item that they make clickable through JavaScript. When people are using or browsing your web page without a mouse--there are certain people out there who have disabilities that can't use a mouse or just maybe using a user agent that isn't mouse capable--in those cases a lot of times, they'll use the Tab key to tab through the links on your page.

Well, if you're creating those links through JavaScript or having those empty links that are only triggered through JavaScript, then those particular types of links don't receive that focus. So you need to keep that in mind and make sure that all the links on your page are keyboard accessible and people can tab into them. Finally, I want to talk about the ARIA landmark roles, and it's like getting accessible microformat that passes along more information about particular page regions. Now this is especially helpful for navigation because there are certain user agents out there, that will allow you to navigate to a particular region. Now, if you could set it up, for example, as a preference, so always go to the main region so that you are just instantly reading content.

Others you might say okay take me to the navigation. And by applying these role attributes to these regions, you're not only passing along more semantic information about your page, but you are also helping out these assistive devices. It is way more about the WAI-ARIA landmark roles than I can cover right here. So I've given you links to the specification, and I've also given you some general links to the pages on links and hypertext for the WebAIM's accessibility initiative page, so you can learn a lot more about navigation and accessibility there as well.

So before we go, let's just go ahead and take care of those landmark roles. There are certain landmark roles that you want to use, there is banner, there is navigation, there is main, those are the ones that we are going to use in for this particular example. Now there are more out there, so to be sure to check out specification. So I am going to go into header and for header, I am just going to go ahead and give it a role attribute of banner. Now I am going to go down to my navigation here, which in this case is in my ul tag, and I am just going to go ahead and give it a role of navigation. And then finally, I am going to go down to the article, and I am going to give it a role, as well, of main.

Now I know this was sort of a long movie, but actually those are just some of the basic things that you can do to make your links more accessible. Now if you want to find out a little more about it, be sure to check out the link on this page down here at the bottom to the WebAIM's page on links and hypertext, there is a lot of good information there. And don't forget to go ahead and read the WAI-ARIA specification as well. There's information on all those roles that we covered as well as a lot more information about how to make your pages more accessible.

Show transcript

This video is part of

Image for CSS: Styling Navigation
CSS: Styling Navigation

53 video lessons · 18194 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 3m 8s
    1. Welcome
      42s
    2. What you should know before watching this course
      1m 12s
    3. Using the exercise files
      1m 14s
  2. 35m 25s
    1. Organizing menus with lists
      4m 26s
    2. Ensuring accessibility
      9m 3s
    3. Using the nav element
      7m 30s
    4. Creating block-level links
      3m 8s
    5. Lab: Structuring navigation
      4m 11s
    6. Solution: Structuring navigation
      7m 7s
  3. 48m 42s
    1. Exploring link style considerations
      9m 2s
    2. Using global link styles
      9m 56s
    3. Styling link states
      10m 57s
    4. Indicating external links
      10m 4s
    5. Styling image links
      8m 43s
  4. 52m 5s
    1. Stripping default list styling
      4m 34s
    2. Defining link dimensions
      6m 0s
    3. Setting link styling
      3m 36s
    4. Aligning links vertically
      4m 11s
    5. Controlling link spacing
      2m 30s
    6. Styling menus with borders
      2m 32s
    7. Creating rollovers
      4m 45s
    8. Restricting link styling
      3m 31s
    9. Lab: Creating a vertical menu
      11m 44s
    10. Solution: Creating a vertical menu
      8m 42s
  5. 54m 58s
    1. Stripping list styling
      3m 35s
    2. Displaying links horizontally
      6m 14s
    3. Clearing floats
      6m 12s
    4. Controlling link sizing and spacing
      3m 11s
    5. Styling links
      7m 16s
    6. Creating rollovers
      5m 52s
    7. Indicating current pages
      4m 43s
    8. Controlling cursor states
      2m 46s
    9. Lab: Creating horizontal menus
      6m 45s
    10. Solution: Creating horizontal menus
      8m 24s
  6. 55m 35s
    1. Overview of dropdown menus
      1m 17s
    2. Structuring submenus
      5m 56s
    3. Styling submenus
      6m 4s
    4. Creating submenu rollovers
      3m 28s
    5. Positioning submenus
      5m 43s
    6. Controlling submenu display
      5m 5s
    7. Creating persistent hover states
      5m 53s
    8. Animating menus with CSS transitions
      6m 29s
    9. Lab: Dropdown menus
      6m 51s
    10. Solution: Dropdown menus
      8m 49s
  7. 58m 7s
    1. Creating CSS-only buttons
      8m 39s
    2. Creating special effects for buttons
      4m 2s
    3. Enhancing buttons with gradients
      7m 40s
    4. Overview of CSS sprites
      3m 30s
    5. Using CSS sprites for icons
      14m 30s
    6. Styling block-level links
      8m 38s
    7. Lab: Enhancing navigation with CSS
      5m 26s
    8. Solution: Enhancing navigation with CSS
      5m 42s
  8. 6m 29s
    1. Additional resources
      6m 29s

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 CSS: Styling Navigation.

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.