Skip to navigation

PCPro-Computing in the Real World Printed from www.pcpro.co.uk

Register to receive our regular email newsletter at http://www.pcpro.co.uk/registration.

The newsletter contains links to our latest PC news, product reviews, features and how-to guides, plus special offers and competitions.

// Home / Blogs

Posted on March 7th, 2011 by Ian Devlin

Making HTML5 work in old versions of Internet Explorer

HTML5 and Legacy Browsers

One of the main reasons why developers may not be making the move to HTML5 as yet is the perceived lack of support for legacy browsers. This is actually untrue, and whilst there might be some jiggery pokery required for proper backwards compatibility, it’s still possible.

Of course, by legacy browsers I mean Internet Explorer, as all the other major players update regularly and their users tend to follow suit: browsers such as Firefox, Safari and Opera have supported HTML5 for a while. Some developers may decide to stop supporting IE6, but for some that’s not an option and, at any rate, neither IE7 nor IE8 support HTML5 either. IE9 will, but it runs on Windows Vista and Windows 7 only, so the other versions will still be around for a long time to come, as we have seen with IE6.

So what needs to be done to get HTML5 working in Internet Explorer?

Unknown elements

Well first and foremost, IE won’t render any elements it doesn’t recognise, so it will completely ignore HTML5 structural elements such as header, footer, article, section, and nav, all major parts of a HTML5 site. This can be rectified by telling IE about these elements using JavaScript. The best way to do this is to include the HTML5 shiv script, created by Remy Sharp. This handy script creates all the relevant HTML5 elements which IE will now know about when rendering the page.

One problem with this is that it won’t work for users who have JavaScript turned off. Unfortunately there is no way around this, so a decision has to be made by the developer to either use HTML5 or stay with HTML 4.01.

Styling

Most browsers have internal stylesheets that, amongst other things, apply display:block to block level elements. Whilst some of the newer browsers now do this for the relevant HTML5 elements, some don’t, and this needs to be added for all browsers. Simply adding the following styling will do the trick:

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

Form elements

And what about some of the new elements themselves, such as the new input types - how do these render on legacy browsers?

Fine actually. Since the HTML5 spec was extended in a backwards-compatible way, any input types that aren’t recognised, are simply treated as text and will simple be rendered as so.

Multimedia

As I’ve discussed in the past, the video and audio elements are designed to allow a fall back to Flash, which will work fine on Internet Explorer.

The move to HTML5 will still be a gradual one, and some won’t see nor have the need to use any of the new functionality that it provides, but when they do, they can be (relatively) safe in the knowledge that older browsers will render their sites just fine.

Tags: , , ,

Posted in: Real World Computing

Permalink

Follow any responses to this entry through the RSS 2.0 feed.

You can skip to the end and leave a response. Pinging is currently not allowed.

8 Responses to “ Making HTML5 work in old versions of Internet Explorer ”

  1. Gareth Says:
    March 7th, 2011 at 11:32 am

    I think a lot of developers are scared to start utilising HTML5’s awesomeness because you have to rely on JavaScript being turned on for IE to recognise certain new elements.

    Though HTML5 is more than just new elements and people can use the doctype straight away, I think the HTML5 shiv scares a lot of people away, which is a great shame.

     
  2. Andy Says:
    March 10th, 2011 at 3:47 pm

    Did you mean HTML5 shim? A shiv is a knife ( http://en.wikipedia.org/wiki/Shiv_(weapon) ) whereas a shim is a way of fitting things together ( en.wikipedia.org/wiki/Shim ). Or maybe IE really has hacked you off!

     
  3. Ian Devlin Says:
    March 10th, 2011 at 3:52 pm

    Both! There’s a shiv (http://code.google.com/p/html5shiv/) and a shim (http://code.google.com/p/html5shim/).

     
  4. Mahendra Says:
    March 16th, 2011 at 6:58 am

    i used html5 and script for this but code still showing problem in ie7

     
  5. Steve Haigh Says:
    March 23rd, 2011 at 11:38 am

    So do you think I should be doing HTML5 now? I’m still XHTMLing. I like what HTML5 has to offer, but older browser support does put me off. The javascript disabled issue doesn’t bother me otherly. The majority of users don’t turn it off.

    I’m currently in the process of doing a small refresh on my own site and was wondering how far down the HTML5 path I should go.

     
  6. Yatharth Gupta Says:
    November 8th, 2011 at 6:32 am

    Hi, you can use below modernizr by simple refering the javascript generated http://www.modernizr.com/.

    Thanks
    Yatharth (yatharth@gmail.com)

     
  7. Laurie Mann Says:
    May 4th, 2012 at 6:57 pm

    I’ve been playing around with HTML5 and like what I’ve seen. I reformatted a Website I run for a group, and, as usually, the people who are religious about not upgrading their browsers (or who work for companies that are still running IE8) are complaining the most. While I’ve been formatting sites for XHTML for years, I think I will shift over to HTML5 over the next few months.

     
  8. Ian Says:
    May 7th, 2012 at 8:32 am

    Hi Laurie,

    What are the IE8 users complaining about? As the article shows and hints at, in most cases you can provide fallbacks for older IEs to work fine.

     

Leave a Reply

Spam Protection by WP-SpamFree

* required fields

* Will not be published

Authors

Categories

Archives

advertisement

SEARCH
SIGN UP

Your email:

Your password:

remember me

advertisement


Hitwise Top 10 Website 2010