Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
For our last exercise on tables before we get to our lab, I want to discuss making your table data a little bit more accessible. Accessibility really matters when it comes to tables. For example, when a screen reader has to read through a table structure, tables can get very, very complex, and it can be very easy for the user to become confused about what data applies to what other data and the order that things are being read and the information within the table, is it something that they want to read through in the first place? Not just for screen readers, but for really any type of device that's going to scan through your content and pull content out, the more you can make this data accessible and the more that you can make the data relate to each other in a very logical way the more successfully your table is going to be.
So a lot of times we get so caught up in the visual aspect of how something looks in the browser, we really kind of forget that machines read our content just as much as people do and other assistive devices are reading that content as well. We've already done a couple of things here to help make our tables more accessible. For example, we do have a caption. That is one of the best things that you can do. And we got a very short and succinct caption here: Basic table elements. Why I still have that an h1 I have no idea. It's not hurting anything, but I want this to be more realistic, so I'm going to get rid of that.
Below that, we've also used table header tags, and that's going to help make your data more accessible as well because it makes sure that whatever device is looking at these know that this content is special and it relates to the content either beside or below it. The first thing I want to do to help make this table a little bit more accessible is to use yet another attribute up in our table tag. In addition to the border cellpadding and cellspacing that we're using here, I'm going to add one more attribute, and this attribute is going to be the summary.
There's been a lot of debate over summary recently, because, for whatever reason, it's been remove from the HTML5 Specification. It was removed arbitrarily. There was really not a whole lot of debate on it being removed, and there is no clear alternative is to what you're supposed to do. So here's what the summary allows us to do. I'm going to go ahead and in quotation marks, I'm just going to give this table a nice little summary. I'm going to say "A brief description of the basic structural"-- I want to turn Word Wrap on; it's going to be hard for me to keep doing if I don't have it on--elements for building HTML tables. And don't forget your quotation mark there.
And so what its saying is a brief description of the basic structural elements for building HTML tables. Now, compare that with our caption. The caption says Basic table element. It's a lot shorter, much more succinct. It's a visual element, whereas summary is something that you can't see. But what it is it's just a nice definition or description of the table contents. Screen readers will read this, if the user can choose to read it or not, and other devices can retrieve that summary information and learn a little bit more about the table if they'd like.
There was no real clear reason given us to why it was removed from HTML5. And what's worse in my opinion is no viable alternative to placing a summary within your table was given. So there is no other mechanism available to us. So, I'm going to go ahead and just tell you my opinion on this, and my opinion is that there are lots of screen readers and other assistive devices out there that already support table summary, so it's in use; people have been using it for years. It's in the HTML4 Specification. It's going to be supported by devices and browsers for the foreseeable future.
Just because it was removed from HTML5, there is absolutely no compelling reason to not use summary. So, in certain validators you might get a little message that says "oh summary is deprecated; it's no longer valid HTML." You can just fill free to ignore those. So my recommendation is you keep using it. Now other people might feel a bit differently, but I don't see a compelling reason not to use summary on any table that has descriptive data inside of it. One last thing I wanted to here to make this table a little bit more accessible, let's go back to our table header tags for a moment. If I save this and again preview this and more my browsers, the table headers here, we know by looking at it that they apply to the elements below it, so we can just scan a table and tell it visually. But again, not every device is going to be able to scan this visually, so we need to have some sort of mechanism that tells user agents and accessibility devices that, hey, this particular header applies to these particular cells right through here, and we do that by scoping these.
What I'm going to do is I'm going to come right here into the first one and I am going to set the scope of this to col. C-O-L. You'll notice that my options there were col or row. So if your headers are on the left-hand column, for example, and they apply to all of these cells to the right, I could've said row. But by saying column I'm saying, hey, these are scoped so that these headers apply to every piece of data within this column. So that's a nice very quick and easy thing that you can do when you're setting up your headers to make your table a little bit more accessible. So I'm going to go ahead and save that.
There are some other things that we've already completed that help make this table more accessible. I've already mention the caption; that's certainly very helpful. But as you begin to create your tables, concentrate on creating clean tables they are as simplified as possible. The more complex a table gets the more confusing it becomes. So, if you're interested, be sure to check out the link. It'll take you to the WCAG, or the Web Content Accessibility Guidelines, regarding tables. I highly recommend checking it out.
Get unlimited access to all courses for just $25/month.Become a member
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.
Your file was successfully uploaded.