Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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.
Since this course focuses on the structure and semantics of HTML5, I think it's fair to address, at the outset, a question I've heard more than once: Do we really need new structural elements? What's wrong with the ones we had? Well, nothing is wrong with the elements in HTML 4 per se, and I think it's important to point out that they're all still there; they all still work and there's absolutely nothing preventing you from using them. Now, to understand why the improvements to structure and semantics in the HTML5 are such a big deal, let's take a look at a sample page.
So here I have html4_plane.htm open, and you can find that, and all the other files that I am going to be working with in this particular unit, in the 01_03 folder. Let's take a look at the page structure really quickly. This should look familiar to anybody that's dealt with HTML 4 before. So here we have a couple of headings, an h1 and an h2, an unordered list, which is responsible for structuring our navigation, and some additional headings and contents that kind of goes down the page. Okay, that's nice, but really, the content is not grouped in any way.
It's not described in any way. There's nothing there telling any type of user agent that might visit this page, what differentiates one section of content from the other. In HTML 4, the tag that we used to group content and basically section it off was the div tag. So I am going to my next file, which is here, this html4_plain2.htm, and you can see here the content is now being separated and sectioned by using this div tag. Now, the div tag is a generic block-level element. It really doesn't mean anything. Semantically, it has no meaning at all.
All it really does for us is allow us to group content together. It's up to us as authors to add any type of meaning to it at all. And typically, the technique that evolved over the years was to add meaning to our div tags through the use of class and ID attributes. So if I go over to html4_plain3.htm, you can see that. So here, now the div tags have ids that explain okay, this is the header, this is our navigation, this is our main content, this is our sidebar--and that's much easier to understand. But the real problem with this, however, is there really aren't any standardized ID and class values.
I can use any ones that I want. I didn't have to use sidebar, for example; I could've used ad or secondary content. So creating a system, any type of user agent that can read and understand the content that I've just created, is not a given, because I can use any IDs and class names that I want, if I'm working within a system but there really isn't one set of standards to guide everybody. Now this problem of providing any type of underlining meaning for what was going on the code is one of the driving factors behind the development of HTML5.
Way back, as far as 2003 and on and up, people began to do studies about the types of IDs and classes that folks were using out there, and I am going to point you to a couple of those. First, go to code.google.com/webstats, and if you scroll down, you'll see a study on the number of classes that was done. The study was done in 2005, and it's a sample of over a slightly a billion documents. They were looking to see what types of class values people were using when they identified their content. And this helps us see patterns that are merging.
What types of class names are people using over and over again? How are they describing their content? John Allsopp did a nice study in 2005. You can find this one on his blog 'dog or higher'. Just go through the archives into November 05 of 2005 and you can find this article which contains a really nice study of the current level of semantics in HTML documents. And again, he is going to give you a sampling of some of the class values and ID values that people were using. Opera did another study as well, and that's the one I really want to look at.
So let me switch over here to the ID attribute list study that Opera did. Most people were defining sections of contents through IDs rather than classes. It's valuable to look at both of them, obviously, but when people started looking at these class and ID values for this wide range of pages, some patterns began to emerge, and you can see them here in the Opera study: footer, content, header, logo, container. So when you take off the clearly non- semantic elements, such as table1, layer1, autonumber1, you begin the see some patterns. Search, nav, logo, header, container-- those are the driving forces behind the creation of these new semantic tags within HTML5.
So, coming up with a standard set of tags would give everybody the ability to consistently identify and define content, which in turn is going to make it easier for web applications and user agents to parse that content and return the proper data. Let's re-imagine this page in HTML5. So I am back in the code here in Dreamweaver and I have html5.htm opened up. And you see, the exact same page, but now were using those descriptive semantic tags that HTML5 gives, us and it's a lot easier to tell what's going on.
There is the header, there is our nav, an article, an aside, and a footer; all of that makes sense to us, in terms of what these tags do. Even right off the bat, if you haven't heard anything about the tags, it's pretty easy to identify where the navigation for the page is, by just finding the nav element. Now as easy as that is for us, it's even easier for user agents. So, imagine the assistive technology, for example, knowing exactly what the content of this element is because it's a nav element, and you can start to see some of the attraction to these HTML5 semantic elements.
Now, IDs and classes are still there. If we want to extend the meaning of these new elements, we're free to do that. So if I move over here to html5_2.htm, you can see I have extended the meaning of article by giving an id of mainContent. So if I have multiple articles on a page or multiple asides, it's fine for me to go ahead and use classes and IDs to further identify them as well. So, what does that mean to your viewers? Well, I'll be honest with you--not a lot. You can see here back in Firefox I've loaded up the first page that we looked at, which was just that plain html4 document.
So now, let's take a look at the same document, divided by diff tags. Now, the same document with div tags and ID and classes attached to it. The same document in HTML5, and the same document in HTML5 with IDs and classes assigned to it. So, no huge differences. You might have noticed a slight difference between this and this, but the only thing that changed there was the actual heading tag that I used for a specific section, because there are slight differences in the syntax between HTML 4 and HTML5 regarding the use of headings. So as you can see, all of the versions of this page that I've shown you look exactly the same in the browser.
So let's be honest, the structure and semantic markup of the page is not for the viewer. Without looking at the code, viewers would have no idea which page is which. However, browsers, accessibility devices, or other user agents will notice the difference, and that's the point of our new semantic markup.
There are currently no FAQs about HTML5: Structure, Syntax, and Semantics.
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.