Viewers: in countries Watching now:
Gain a deeper understanding of HTML5 and learn how to create richer, more meaningful web pages with structural tags and descriptive attributes. In this course, author James Williamson presents an overview of HTML5 and its development, defines the new tags and attributes, and discusses how browsers parse and display HTML5 content. The course also includes step-by-step instructions for constructing an HTML5 document with a header and footer, navigation, content groups, and formatting.
Sometimes even minor changes to a specification will cause problems, such as the case with the cite element. Now, if you're not aware of the cite element or the changes that have been made to it in HTML5, don't worry; its focus is pretty narrow, and there's a good chance that you probably just never needed it before. However, it does provide us with a chance to give our content even more semantic meaning, so it, and the changes that have been made to in HTML5, are worth looking in to. I'm here in the HTML5 specification, and I've navigated to the cite element.
I want to take a look at what the specification has to say about it, so I'm just going to scroll down to look inside the definition. So what the definition says: "The cite element represents the title of a work," and then it gives a couple of examples of those, books, papers, poems, paintings, things like this. Now this can be a work that is being quoted or referenced in detail, i.e. a citation, or it can just be a work that is mentioned in passing. Okay, that doesn't sound all that controversial, does it? Well, it's the second paragraph that's causing some problems. So, let's read that. "A person's name is not the title of a work -- even if people call that person a piece of work." So I've never read a specification that's kind of snarky, but this one is.
"The element must therefore not be used to mark up people's names." So what's the problem with that? Well, that's not what the spec said in HTML 4, and in fact, authors have been using cite when quoting or, citing, if you will, author's names for quite some time now. That means that the HTML5 specification is now making past usage of the element non-conforming. This goes directly against what the specification was supposed to do, which was to ensure backwards compatibility.
Now, as a result, many well-respected authors and I guess some non-well- respected authors like myself are simply telling people to just ignore the specification and keep using it the way they've always used it. Hmm, don't you just love the evolution of the web? Now, exactly how you use the cite element is up to you as an author. For our Trails page, we're going to go ahead and use the cite element, along with a few others, to add a little bit more semantic richness to our document.
So here we are, back in our Trails file, and this one you can find in 05_06 directory. I want to scroll down a little bit and I can see at about line 68 or so, we've added some content to our Trail Review. And this content is not currently marked up, so that means we're going to have to mark it up. Okay, so we can see that the content says, "Northridge Loop is easily the best loop in Ojai! You'll kick yourself if you miss it!" Apparently, that is Nick Brazzi's opinion, and that is coming from his latest book, The Complete Guide to Trails.
Okay, so this is definitely a work that we're citing from, and it's a quote. So there are a couple of things going on here. Number one, I don't want this information to show up in the document outline. Number two, it's definitely not part of my main body of text, so I need to start at least, not a new section, but it needs to have some means of identifying itself as being related to, but separate from, my main text. Well, a good candidate for use here would be a sectioning root element whose internal structure is hidden from the document outline, and the one that really immediately comes to mind with this is blockquote, and I think blockquote would be perfect here.
So what I'm going to do is just in front of this line of text, I'm going to go ahead and wrap this entire quote, both lines of it, with a blockquote tag. Cool! Okay, now the next thing I want to do is structure the inside of the blockquote, again to sort of denote the meaning of everything that's going on here. The first line that I look at, "Northridge Loop is easily the best loop in Ojai! You'll kick yourself if you miss it," that's a quote, and there is definitely an element that is built specifically for this purpose and that would be the quote tag.
So I'm going to go ahead and use the q tag here. Now if you've never used the quote tag, it's actually been around for a little while, and it does just that; it identifies its contents as being a quote from somebody. What's really nice about this, other than just the semantic meaning we get from using the tag, is in the browsers, most user agents will go ahead and place the quotation marks there for you, so that's not something you have to do yourself, or worry about placing in there, which is really nice. Now I need to take a look at the rest of the blockquote, the remaining line which is Nick Brazzi, and then the work of his that we're citing from.
Here, I want to add a little bit more structure to my blockquote, and your blockquotes can have as much or as little interior structure as you want. When I take a look at what's happening here, this is some information that is identifying the author of the quote itself. And if we look at a semantic tag that allows us to give information about the author of something, then the footer comes to mind, and footer is absolutely perfect for this. So what I'm going to do is right here in front of Nick Brazzi, I'm just going to go ahead and open up a footer tag.
Then I'm going to wrap this whole line, and I'm just going to go ahead and offset this so that you can really see the structure of it. So now our author's name and the work is inside a footer which is inside the blockquote. So it gives some information about what that content is and how it relates to the rest of the blockquote. Now, the last thing we want to do is we want to go ahead and use the cite element. And despite what I said-- yes, we could use it on the name-- but despite what I said, I want to do it in conformance with a specification. So what I'm going to do is right here for The Complete Guide to Trails, I'm going to go ahead and use the cite element right there.
I'm just going to go ahead and wrap The Complete Guide to Trails, which is the work, in the cite element. So I'm going to go ahead and save this, and I'm going to preview that in a browser. Now, as I scroll down, cool, I can see our blockquote. You can see that the quote element is going ahead and the browser is adding quotation marks for us, which is very nice. The other thing that the footer does, other than identifying the author information for the particular blockquote, is it gives us another styling hook, so we're able to style the blockquote one way and the footer in other, and it gives us sort of a nice visual effect here as well.
So blockquote, quote, and cite, all three of those give us some really powerful tools when quoting or citing from other works. Now, how you use these elements is, again, entirely up to you as an author. Just make sure that you're familiar enough with the specification, so that the meaning that the elements impart matches the meaning that you're trying to convey.
There are currently no FAQs about HTML5: Structure, Syntax, and Semantics (2011).
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.