Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We're going to take a slight break from our Trails page for just a moment to talk about lists. Now if you've been authoring web pages for any time at all, you're probably pretty familiar with at least two types of the lists available to you in HTML. I mean most web authors, for example, have used an unordered list or an ordered list probably pretty frequently, and they're especially handy, for example, when you create navigation. Now for the most part, lists remain unchanged from HTML 4 to HTML5; however, the ordered list and the definition list have changed a little bit, so I want to discuss those changes and maybe experiment a little with what we can do with definition lists in HTML5.
So first things first. I want to go to the specification. I'm here in the author view and I've navigated to the ordered list element. Now, I want to point out just a couple of really minor changes, but they are changes that could have a big effect on you. Now first off, the start attribute right here, which was actually deprecated in XHTML, is back. Now what this does is it allows you to change the value of where the list begins its count. So this is good, since most browsers never really stop supporting it anyway. So feel free to go back and use it if you want.
Now let me go back for just a second. They've also added a brand-new attribute, which is reversed. And what's really neat about reversed, this is a Boolean value, meaning you can just say reversed on the list, and if it's found, it's true. Now this allows you to create a list that basically counts backwards. That's really cool, but unfortunately, as of yet, nobody's gotten around to supporting it. But once they do start supporting it, it's going to be a neat capability to have. As for the definition list, a little bit of clarity has been added. Now previously, in HTML 4, a definition list was defined as a list containing a term and one or more definitions for that term.
Now, this didn't really reflect how authors were using the definition list, as people were using it for things like bibliographies, indexes, and really all sorts of non-definition list lists. So now, let's take a look at what the definition reads, and I am just going to scroll down a little bit. So here we have, "The dl element represents an association list consisting of zero or more name-value groups." And if we go down a little bit further, "Name-value groups may be terms and definitions, metadata topics and values, questions and answers, or any other groups of name-value data." All right! So that means as long as there's a clear relationship between the name-value pairs, almost anything can be described by a definition list.
And honestly, that's really simply bringing the specification up and recognizing how authors were using the definition list in the real world anyway. Okay, so what we're going to do is we're going to go back into one of our pages and take a look at how we might use it. Okay, so I've opened up the all_trails.htm. So we're working on sort of a new file here, and you can find this in the 05_04 folder. Now, I want to scroll down a little bit, and I can see that what we're basically looking at now is a list of all of our trail reviews.
So if you think about the way our Trail Review page functions, obviously, we're looking at a specific article normally, but this time we're looking at all of the trails that have reviews available to them. So after the header content, we have an h3 tag that says All Trails, and then we have a listing of all the individual trails and then links to those trails. Okay, so this type of structural content where you have kind of a heading and then individual items within that heading, that is a perfect structure for what definition lists allow us to do now in HTML5.
So that's exactly what we're going to do here. We're going to structure these links in definition lists rather than an ordered or unordered list because the structure just lends itself to that a little bit better. All right! So I'm going to go ahead and create a definition list right above the first element, and I'm going to go all the way down to our last one and close out the definition list. So the dl tag is the opening definition list tag. Now after that, we have two tags to choose from: a dt which is the term, and a dd which is the definition.
So essentially, those are your name- value pairs, and the term typically comes first and the definition typically comes after that. And you can have as many definitions within a term as you want. So, the way that we're going to be using this is that each of the areas is going to be a term, and then the individual reviews inside of that will be a definition. So I'm going to highlight Butte. I'm just going to wrap that in a dt tag, and then each of the individual trail reviews inside of that are going to get the dd tags. Perfect! So those are going to be the definitions. So I'm just going to go ahead and do that all the way through.
Now while we're doing this, it gives us a good opportunity to talk about different structures and different cases where a definition list would be pretty helpful. Now I mentioned earlier before that a lot of people use them for things like bibliographies. I've seen people use them for comments in blogs. So you might have a threaded comment section where you have the definition term being the opening comment and then the definitions inside of those being the actual comments themselves. So really, any structure where you have sort of this repeating structure is a good case use for a definition list.
You have those name-value pairs, and remember, the inside of the name-value pairs can be anything that you want them to be. You're not limited to links or paragraphs or just text. You can have images. I've seen people do images inside of them. You can really do anything you want with them. Now, to avoid you having to watch me do all this, what we're going to do is I'm just going to skip to having these all done. If you want, you can just pause the video and then finish this structure up and then un-pause it when you're done, and we'll pick back up from there. All right! So I'm just finishing up my last one here. There we go.
You can see, I know there's a lot of them, but we've got a lot of tour reviews, don't we? So you can see the structure of this, individual definition terms for the regions themselves, and then the definitions inside of them are the actual tour reviews. So if I save this and test it in the browser, we can kind of see our structure. I styled through CSS, and these are all links to our trails. So I think it's easy to see that in certain instances, the structure that the definition list, and really all the other lists in HTML5 afford you, allow you to structure your content in a more meaningful way.
So we didn't have to use a table here. We didn't have to use headings and paragraphs. We were able to use the definition list, which group all these links together, lets people know that they are related, they do belong together, and yet we still get the advantage of using the name- value pairs that the definition list gives us. So the changes that were made in the specification to both the ordered list and the definition list are minor on the face of them. But especially the changes to the definition list are going to allow authors to continue using them as they have in the past, with really a clear conscience about being in conformance with the specification.
Now the tweaks they made to the order list are going to be helpful as well, especially once the reversed attribute is supported.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97398 Viewers
61 Video lessons · 84633 Viewers
71 Video lessons · 68840 Viewers
56 Video lessons · 101296 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.
Your file was successfully uploaded.