How do I tell if Browser supports HTML 5

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
jcobban
Forum Commoner
Posts: 41
Joined: Mon Mar 08, 2010 7:40 am

How do I tell if Browser supports HTML 5

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do I tell if Browser supports HTML 5

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: How do I tell if Browser supports HTML 5

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do I tell if Browser supports HTML 5

Post by pickle »

Actually the video/audio tags work just fine with no Javascript. JS is only needed if you want custom controls.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: How do I tell if Browser supports HTML 5

Post 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.
jcobban
Forum Commoner
Posts: 41
Joined: Mon Mar 08, 2010 7:40 am

Re: How do I tell if Browser supports HTML 5

Post 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?
Post Reply