New Semantic Elements (Part 2)
New Semantic Elements (Part 2)
Elements
(Part 2)
Three More New HTML5 Elements
The <article> element represents web content that could
stand by itself, even if separated from the surrounding
page information.
The <aside> element represents content that is visually
set apart from the main content of the page, yet is still
somewhat related.
The <section> element is a generic area of a web
document that groups related content.
Along with <header>, <footer>, <nav>, and the all-purpose <div>, these three
elements make up the basic building blocks when designing site layouts. Let's
look at each one in turn.
The <article> Element
The official specification for <article> states that it is “a self-contained
composition in a page that is independently distributable or reusable, e.g. in
syndication. This could be a forum post, a magazine or newspaper article, a
blog entry, or any independent item of content.”
The key concept in the above definition is that it is self-contained. The
<article> element was designed for content that can be extracted from its
containing page and still retain its full value.
In HTML5, there can be multiple <article> elements on a web page. In fact,
this is fairly common. For example, a typical blog has several different blog
posts visible on the home page, with the most recent post at the top.
article {
margin: 15px;
padding: 10px;
background-color: #EEEEEE;
}
The <aside> Element
The official specification for <aside> is “a section of a page that consists of
content that is tangentially related to the content around it, and which could
be considered separate from that content. Such sections are often
represented as sidebars in printed typography.”
It goes on to state that <aside> “can be used for effects like sidebars, for
advertising, for groups of nav elements, and for other content that is
considered separate from the main content of the page.”
The most common uses of <aside> are for links to external websites, for
advertising, and for "About Us" or "Contact Us" sidebars.
An <aside> can be nested within an <article> if its content applies
specifically to that article.
<section>
<h2>Home Page</h2>
<article>
<aside>
...
</aside>
...
</article>
</section>
section {
background-color: #FFFFCC;
padding: 5px;
}
We could now add more articles to be
contained within the main <section>.
Site Layouts Using HTML5
We have now covered all the basic building blocks for laying out HTML5-based websites:
Don't forget that the <div> element is still a common component when designing web page
layouts in HTML5. For this lesson, though, we are focusing on the new semantic elements.
Example Site Layouts
This layout closely resembles the sample
page we just created during this lesson.