Page 1 of 1

How do I tell if Browser supports HTML 5

Posted: Sat Oct 30, 2010 3:52 pm
by jcobban
The response from get_browser() does not indicate whether or not the browser supports HTML5. How exactly do I determine this? Every HTML5 related web site I go to just tells me how wonderful HTML5 is, and how it is going to solve all of my problems, but not how to migrate in a mixed browser environment.

Re: How do I tell if Browser supports HTML 5

Posted: Mon Nov 01, 2010 10:55 am
by pickle
The idea is HTML 5 is supposed to be backwards compatible. So, if you code properly, even browsers that don't understand HTML5 should still be able to render the page. I don't think there's anyway on the server-side to tell if the browser supports HTML5.

Re: How do I tell if Browser supports HTML 5

Posted: Mon Nov 01, 2010 3:25 pm
by kaszu
HTML5 features like video, drag and drop, web storage, etc. are useless without javascript, so there is no need to know about html5 support on server-side, at least I couldn't think of one.

Re: How do I tell if Browser supports HTML 5

Posted: Tue Nov 02, 2010 9:47 am
by pickle
Actually the video/audio tags work just fine with no Javascript. JS is only needed if you want custom controls.

Re: How do I tell if Browser supports HTML 5

Posted: Tue Nov 02, 2010 10:10 am
by Weirdan
pickle wrote:So, if you code properly, even browsers that don't understand HTML5 should still be able to render the page.
Unfortunately, not every browser (*cough* IE *cough*) does. For example, IE does not support new html tags like <section> or <aside> and requires a little bit of scripting to overcome this limitation. This could be solved on client-side though.

Re: How do I tell if Browser supports HTML 5

Posted: Thu Nov 04, 2010 11:44 pm
by jcobban
Weirdan wrote:
pickle wrote:So, if you code properly, even browsers that don't understand HTML5 should still be able to render the page.
Unfortunately, not every browser (*cough* IE *cough*) does. For example, IE does not support new html tags like <section> or <aside> and requires a little bit of scripting to overcome this limitation. This could be solved on client-side though.
As you point out IE, at least IE<8, does croak on HTML5. One aspect of this is IE's "quirks" mode. Because IE started out with a totally unique DOM it has to know what flavor of HTML it is processing in order to tell exactly which version of its DOM to invoke. IE therefore looks at the <!--HTML line to identify the HTML version. When IE<9 sees the HTML5 version of this line it doesn't understand it, and IE7, at least, falls back to some very strange behavior. Since IE7 is the browser on millions of WinXP machines that are not going away soon, I cannot afford to ignore its peculiarities.

I am trying to code defensively. That is my HTML5 web pages avoid use of HTML5 only tags and attributes as much as possible. But doing so means I cannot exploit many of the features of HTML5. What is the point of coding in HTML5 if I can only use HTML4.1 features? I therefore need to know whether or not the browser understands HTML5 so I can generate those tags and attributes when my application can take advantage of them.

So instead of uttering blatant nonsense, such as that every browser still deployed is never going to go haywire when it encounters some HTML5 feature, just answer my question: How do I tell in PHP, short of testing every browser out there and creating my own equivalent of browscap.ini, whether or not it is safe for me to emit HTML5?