0

currently I am working on project where I have to detect does clients browser supports HTML5 or not, I am using following script to detect HTML5 support it works fine in all browsers except IE.

   function getHTML5VideoSupport() {
    if (!IsAttributeSupported("video", "src")) {
        return false;
    }

    else {
        return true;
    }
}

this method returns true if browser supports HTML5 else false. but problem is in IE, and I also have to check for CSS3 support.

1
  • 1
    Where's the code for IsAttributeSupported()? Are you only trying to detect HTML5 video support? Commented Dec 28, 2011 at 7:24

1 Answer 1

6

Neither HTML5 nor CSS3 is an all or nothing proposition. You can't say a browser 100% supports it or doesn't support it as both are a whole grab bag of individual capabilities.

The safe way to check for support is to identify the particular features that you need and use feature detection to see if they are supported or not.

For example, IE9 supports pieces of CSS3, but not CSS transitions. HTML5 consists of many different pieces which are again supported differently by different browsers and different versions of the same browser. There's one set of tests for HTML5 audio, yet another for local storage, canvas, hash change events, web sockets, etc...

The feature detection library modernizr contains a wide array of feature detection capabilities that can let you test for exactly the capabilities your app needs using well-tested code. You can either include the whole library or copy just the pieces you need into your own app.

So, to test for CSS3, you'd have to identify exactly which capabilities you need in CSS3 and identify feature tests for those particular capabilities.

See this article for more info about feature detection for individual HTML5 features.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for your kind reply but my question is how I detect clients browser does supports HTML5 or not my above given script does not works on IE
@Sameer - You don't seem to understand. There is no single test that detects HTML5 or not. HTML5 is a collection of hundreds of features - some of which may be supported and some of which may not in any given browser. Which exact feature are you interested in testing for? Only HTML5 video?
@Sameer - added reference to this article about detecting individual HTML5 features.
Jfriend00 thank you for sharing your kind experience, now i am using border radius property of css3 and html5 video and Audio tags of HTML5 for testing HTML5 support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.