Use HTML 5 Elements in IE 8 using HTML 5 Shiv

There are a lot of new HTML 5 elements like <header>, <article>, <footer> etc. that browsers like IE 8 and versions prior to that, do not support. These browsers need some help recognizing the new HTML5 elements and Remy Sharp’s HTML 5 Shiv provides just that.

To use this script, it must be included before the <body> element (i.e. in the <head>).

To improve performance, include the CSS first and then this script. Here’s how to declare this script

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

This script enables IE to acknowledge the new HTML 5 elements by directing it to create the elements using JavaScript. The conditional comment shown above only loads the html5 shiv code when the version of IE is lower than 9.

You also need some CSS styling to render the elements as  block-level elements

image

1 comment: