Start learning with our library of video tutorials taught by experts. Get started
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.
You may have noticed when we were looking at the new HTML5 elements, the specification listed which categories of elements the elements belonged to. These categories refer to the new content models in HTML5. Since they present a huge shift in how content is defined, it's important to understand how these content models in HTML5 work. In HTML 4, elements typically belonged to one of two content models, either block-level or inline. Block-level elements, such as paragraphs, div tags, and headers, would occupy their own line within the document flow, whereas links, emphasis tags, spans, things like that, those were inline level elements, and they're typically found within the content of block-level elements.
Now for the most part, it was this distinction that determined document structure. Now because of the increased emphasis on semantics and structure in HTML5, several new content models have been introduced. Now what's more, elements may actually now belong to more than one content model category. This allows you as now author to create more sophisticated document structures and to write more meaningful code. So I want to illustrate this a little bit using the actual specification, so here I am in the author view, and I am in section 3.25, the Content models.
And I just want to scroll down a little bit because there is a list of the content models. Here we go. So we have seven types of content now inside HTML5. So metadata content, flow content, sectioning content, heading, phrasing, embedded, and interactive content. Now let's take a look at these individually, and I'm going to do them slightly out of order than the list has them here because I want to emphasize a couple of these towards the end. So the first one I want to take a look at is metadata content. Now metadata content, again, it's content that sets up the presentation or the behavior of the rest of the content, and you'll primarily find these elements in the head of the document.
Sample elements could be a like the link tag, the meta tag, noscript, script, and title elements. I'm just going to hit the Back button to go back up to this list, and I'll just continue to kind of go back and forth here. Now the next one I want to talk about is embedded content. Embedded content is any content that imports other resources into your document. So some of these elements might be the object element, video, canvas, so you've probably heard a lot about video and canvas, and the embed element. So these are all part of the embedded content model.
Going back up to our list, I next want to take look at interactive content. Now interactive content is any content that is specifically intended for user interactions, such as user interfaces, forms, and controls. Some of the sample elements include the link tag, a tag, details which may or may not remain in the specification. It hasn't been implemented yet. There is a lot of debate about that. The object element and the video element, if the controls are enabled on the video, that would obviously make something that you could interact with. So notice that a trend is developing here, that most of the time instead of looking at to how the browser should display the content, it's really focusing on the type of content that you're describing.
Now, if we go back to our list, the next one I want to talk about is heading content. Now the heading content defines the header of a section. Now this can be either explicitly marked up with sectioning elements, or it can be implied by the heading content itself. Now heading content elements contain all the heading tags that you are really familiar with, h1 through h6, and something that you might not be similar with-- the hgroup element. I do want to point out something here. Look at all the elements that are listed here as belonging to the heading content. The header is not in it.
So the header element itself is not considered part of the heading content; it's merely a section of introductory content. So even though you might automatically sort of place it there, it doesn't really go there. And the next content model I want to take a look at is phrasing content. There are a lot of things going on here. Phrasing content is really the text of the document, as well as any elements that are used to mark up the text within paragraph level structures. And in many ways, the phrasing content is sort of the same as inline level elements from the HTML 4 specification.
So you can see there are a lot of elements involved here. Some of them are the link tag, a tag, emphasis tag, image, a label mark, which we'll cover a little bit later on, span tag, and the strong tag. Now there is a note here that I want to read, "Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not just any flow content." So there is that sort of kind of inline nature of them, that most things that are considered phrasing content can only contain other elements that are phrasing content.
Now that's not a hard-and-fast rule. There are exceptions to that, and we're going to see some of those exceptions a little bit later on. Next, I want to cover a little bit about flow content. Now, flow content, this is the big one. This contains the majority of all of your elements in HTML5. You can think of these elements as elements that would be included in the normal flow of the document. Although we're looking at the author's view of the specification, it is important here to mention something from the larger specification. How flow content is displayed is left entirely up to the user agent.
There are no rules governing whether the content displays as inline or block-level elements. Don't assume that just because it's flow content that it's going to be a block-level tag or display as a block-level element. Some of the sample elements here, once again the link tag, a tag, anchor tag--we're seeing that everywhere, right? article, aside, blockquote, canvas, details, the div tag, and emphasis tag, form tag, heading tags, hgroup, nav. I mean I can go on and on here. As you can see, really, if it can fill within the body tag, it's probably considered part of the flow content.
Now the last group of content that I want to describe, and I did save this for last on purpose, is the one that we've been referencing all throughout this chapter, and that's sectioning content. Sectioning content is content that defines the scope of the headings and the footers. It's really important to say that. This defines the scope of them. Any use of these elements creates a brand-new section within the document, and that's something that's really, really crucially important, that we're going to talk about in an entire chapter all by itself. So I am going to say it again, use of these elements creates a new section within the document. We don't have very many of these.
Notice that the only sectioning elements that are listed are the article, aside, nav, and section elements, and those are all of course things that we've been using for a while now. You may have noticed at this point that several elements appeared on the multiple content models. For example, it seemed like no matter which one we went to, there was the anchor tag. I am going to scroll down a little bit here directly from this list that we've been using, and show you this Venn diagram that is here in the specification. Basically, I'm going back to that anchor tag, it's part of the flow, phrasing, and interactive content models, depending upon how it's being used.
So as you can see from this diagram, there are several overlapping areas of content types. Now, almost all content is contained within the flow content model. The phrasing, embedded, interactive, and metadata, they're all somewhat related to each other. Sectioning and heading content are separate within the flow content, and those guys what you're going to use to define the document structure and outline. So this diagram helps to sort of explain that relationship. Keep in mind that HTML5 is concerned with the structure of the markup of content, not the presentation, whereas before, when you had rules about how block-level and inline level element should be displayed, now the display of the elements is left entirely up to the user agent and the CSS that the author is going to employ. While there are rules about which elements can be contained within one another, there is nothing to stop you from displaying images as block-level elements and list items as inline-level elements.
This is really nothing new; authors have been able to do that through CSS for years now. So for the most part, it's simply the HTML specification finally reflecting the reality of how HTML and CSS should work together.
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.