We are a web design and development agency based in Manila and this is our blog. We build web applications that help companies run their businesses and help people find their voice on the web.

HTML5 Section Element

Posted by Kevin Bett over 1 year ago

One of the new HTML5 elements is section which should be used to separate and group together related content. Wait a minute? Isn't that the trusted div, well not really. The section element is designed specifically to group together related content whereas the div element is a more generic content container.

<section>
 <h1>All about HTML5</h1>
 <p>This is all about HTML and nothing else</p>
</section>

Browsers won’t apply any default styling to the new elements. So, at the very least, you will want to declare that the new structural elements should force a line break:

section, article, header, footer, nav, aside, hgroup {
display: block;
}

That’s enough for most browsers. Internet Explorer has special needs. It resolutely refuses to recognize the new elements. JavaScript genius Remy Sharp has written a handy little script that generates all of the new HTML5 elements. Load this script within a conditional comment so that it’s only served up to the needy Internet Explorer:

<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Now you can style the new elements to your heart’s content.