HTML and CSS Reference
In-Depth Information
Styling HTML5 in Internet Explorer
In current versions of Internet Explorer, your page will be
unstyled. (Actually, it's worse than that: any new elements are
unstyled, but CSS is applied to those HTML 4 elements that IE
does support.)
The way to cajole IE into applying CSS to HTML5 is to use
JavaScript. Why? This is an inscrutable secret, and if we told
you we'd have to kill you. (Actually, we don't know.) If you add
the following JavaScript into the head of the page
IE will magically apply styles to those elements, provided that
there is a <body> element in the markup. You only need to cre-
ate each element once, no matter how many times it appears
on a page.
Remember, HTML5 itself doesn't require a body element, but
this heady brew of Internet Explorer 8 (and earlier versions),
CSS, HTML5, and JavaScript does.
Although this JavaScript is unnecessary for other browsers, it
won't cause them any harm. However, you might wish to give
your page a speed optimisation and only download and execute
this script in IE by surrounding it with conditional comments
conditional-comments/ ).
Whenever you use a new HTML5 element, you'll need to
remember to add the document.createElement for it in the <head> .
Alternatively, you can use Remy's tiny HTML5-enabling script that
will perform this for all new elements in one fell swoop.
NOTE The <script>
element no longer requires
you to specify the type of script;
JavaScript is assumed by
default. This works on legacy
browsers also so you can use it
right away.
Users of all versions of Internet Explorer (currently IE8 and its anteced-
ents) will require JavaScript to be enabled for this technique to work,
although IE9 works like the other browsers and doesn't need JavaScript.
Search WWH ::

Custom Search