Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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.
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.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 100129 Viewers
56 Video lessons · 113153 Viewers
71 Video lessons · 82024 Viewers
131 Video lessons · 39354 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.