HTML5's structural elements (article, aside, footer, etc.) are block-level elements that let you define and style areas of a page without using div's and such. The obvious requirement is to make sure that the browser renders the elements as block-level. Modern browsers appear to treat these new elements properly, but we can make sure that all browsers do so. We use the fact that a browser is generally able to style tags even if it does not recognize the tags themselves. So we simply style our unknown tags to display as blocks, the browser complies, and we have our block-level elements. The easiest way to make sure this happens is to add a reset right into your style sheet.
A couple of examples:
Eric Meyer:
/* HTML5 display-role reset for older browsers */HTML5Doctor.com:
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
article,aside,details,figcaption,figure,These resets, however, do not work with Internet Explorer before version 9, because earlier versions of IE do not style unknown tags. Solving that requires a second trick -- using a script called "the HTML5 shiv." This javascript can be called by simply adding this statement to the head of your page:
footer,header,hgroup,menu,nav,section {
display:block;
}
<!--[if lt IE 9]>The shiv creates elements in the DOM that do not otherwise exist. The reset will then take those created elements and style them as blocks.
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
?</script>
<![endif] -->
We downloaded and played with the actual script itself and found that it even works with a completely fictional tag called <pacs>.
No comments:
Post a Comment