HTML5 Day 1: New tags work in older browsers? Awesome!

14. November 2010

I recently decided to really dig into HTML5 to see what it’s all about. After all, the web (err... tubes) is full of talk about how the new HTML5 Canvas element will bring an end to both Silverlight and Flash. In reality HTML5 is much more than just the Canvas element. In fact, HTML5 brings with it a large list of enhancements, including 28 new elements and form controls that do client-side data validation for you!

Specification Doc or Book?

Instead of reading the enormous HTML5 Specifications, I decided to purchase a book that would sum things up much more nicely. Below is the book:

IntoHtml5SharpLawsonIntroducing HTML5
by Bruce Lawson and Remy Sharp

This book is relatively short at 223 pages and sums everything up very nicely. I’m not finished with the book yet, as I’m playing around with things more rather than reading cover to cover.

I know there are other resources available online (for free), but nothing beats a good book to get you up to speed with a new technology.

HTML5 Design Principles

There are a number of guiding principles that are being used to design HTML5. In my opinion, the two most important principles are:

Degrade Gracefully
”On the World Wide Web, authors are often reluctant to use new language features that cause problems in older user agents, or that do not provide some sort of graceful fallback. HTML 5 document conformance requirements should be designed so that Web content can degrade gracefully in older or less capable user agents, even when making use of new elements, attributes, APIs and content models.“

The specifies that when designing HTML5 it must be done in a way that allows older browsers to gracefully handle rendering HTML5 code to the best of their ability, even though they may not know what certain tags are.

For example, this is what allows you to use the new “email” or “date” Input elements, and they end up being rendered as a standard <input type=’text’/> element in older browsers.

basically <input type="email"/> render as <input type="text"/> and
<article></article> and <section></section> render as <span></span>

Do not Reinvent the Wheel
“If there is already a widely used and implemented technology covering particular use cases, consider specifying that technology in preference to inventing something new for the same purpose.”

This means that certain existing functionality that web browsers already support, but weren’t part of HTML previously, will now be part of HTML5.

One very important feature is the XMLHttpRequest (XHR). You know the object that powers all Ajax calls! XHR was first added by Microsoft to Internet Explorer 5 and support for it has since been added to all web browsers. Even though it was never part of the HTML specification, we all use it. Now with HTML5, it is specified as an object to be used from JavaScript code.

There are other factors that make it possible to use other HTML5 features, even though older web browsers do not natively support them. This is what I’ll cover next.

Using HTML5 in Older Browsers

Even though some of the newer tags in HTML5 will automatically degrade when rendered in order browsers. It would still be nice to fully support those features in older web browsers so that you can start using HTML5 today without worry about it not working if someone is using Internet Explorer 7 or Firefox 3. The good news is you can do just that!

Using the following two tips you can enable the rendering of most of the new HTML5 elements within older web browsers. Some elements, such as the new “date” element, will require further scripting, but this will get you pages to display correctly across new and older browsers alike.

HTML5 Enabling Script
The html5shiv script by Remy Sharp enables all the new HTML5 elements within Internet Explorer versions older than Internet Explorer 9.

To use this script, just place the following markup within the pages <head> tag:

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

This is a conditional comment that tells Internet Explorer version older than version 9 to include the html5shiv script. Firefox and other browsers will correctly ignore this script include since they don’t require it in order to render the HTML5 elements.

Here’s an article by John Resig that explains how this script works: http://ejohn.org/blog/html5-shiv/

HTML5 Reset Stylesheet
Even though the older web browsers don’t natively know how to style the new HTML5 elements, you can include a simple stylesheet in your pages that will tell it how.

<link href="http://html5resetcss.googlecode.com/files/html5reset-1.6.1.css"
    rel="Stylesheet"
    type="text/css" />

Just add the above stylesheet link to your pages before you include your own CSS stylesheets and it will explicitly tell the web browser how to render each of the HTML5 elements.

You can find a little more information about this stylesheet here:
http://code.google.com/p/html5resetcss/
and here:
http://html5doctor.com/html-5-reset-stylesheet/

Additional Resources

I really recommend the book “Introduction HTML5” by Bruce Lawson and Remy Sharp.

If you are looking for additional resources on HTML5, then you should find the following links useful:

Conclusion

I’m really liking the new additions to HTML5, and it’s awesome that you can still use them in older browsers with only a little help.

I plan on continuing this series for a little while, and will post links to subsequent articles below as they are posted.

HTML, HTML, HTML, HTML , , , , , , , , , , , , , , , , , , , ,

Comments

11/16/2010 9:19:47 AM #
HTML5 Day 3: Detecting HTML5 Support via JavaScript

HTML5 Day 3: Detecting HTML5 Support via JavaScript
12/11/2010 9:59:22 PM #
First off, I want to say thank you for taking your time to make <a href="theipodstoreonline.com"><b>the iPod store online</b></a> blog, your helping many people. Thanks!
12/12/2010 4:04:54 PM #
Hey just amazing blog dude! www.justtesting.com
12/12/2010 4:09:44 PM #
Thank you very much for this great article. The best wishes for you Smile
12/12/2010 6:18:36 PM #
Superbly written material, if only all website owners offered the same quality information as you, the internet would be a much better place. Please keep it up! Cheers.
12/12/2010 6:20:03 PM #
There is apparently  a lot to identify about this.  I believe you made certain good points in features also.
12/12/2010 6:31:32 PM #
what is the javascript error which I get always I do tried to replied
12/12/2010 6:37:07 PM #
There is evidently  a bunch to know about this.  I believe you made various good points in features also.
12/12/2010 6:43:29 PM #
I highly recommend trying the e cigarettes if you value your health a lot
12/12/2010 8:29:24 PM #
You really helped me a lot through writing your published writings. may success always be with you. I wait for your next article. Thanks.
12/12/2010 8:37:13 PM #
Very Nice website. I just finished mine and i was looking for some ideas and your website gave me some. The website was developed by you?

Cheers
12/12/2010 9:04:31 PM #
How do you make your blog look this sick! Email me if you can and share your wisdom. !
12/12/2010 9:12:58 PM #
Real   excellent   information can be found on blog  <A href="http://www.bytyuabhui8763.com">here </A>.
12/12/2010 11:28:07 PM #
Hey (author), thanks for bringing freshness in this topic. I have read a lot of articles but nothing with the recent updates about this topic. Your article came as a great help.
12/13/2010 12:31:25 AM #
Hello! Is this Alright if I ask anything kind of off subject? I am trying to check out this page on my  Samsung Galaxy S  but it do not display right, will you have any ideas about this issue? Will i need to get an update for my application or something? many thanks! x Smile
12/13/2010 1:32:12 AM #
Obesity in any form is not acceptable. There are many people who have researched this area over many years with the statistical outcomes comprising one of western standards debasement namely food consuming habits and corporate avarice over customer wellbeing
12/13/2010 3:45:00 AM #
If you are searching for some awesome timber boat plans then dont worry, there are heaps of them if you know where to look
12/13/2010 4:19:39 AM #
I enjoy coming back to your blog. I stumbled on it when I was searching in yahoo. Your information has helped me tremendously. It was exactly what I have been looking for.
12/13/2010 5:01:05 AM #
fantastic column I feel honered to visit your blog
12/13/2010 5:06:57 AM #
Great post, however only some of the points were actually treated really good, I think digging deep for that topic to make it more informative will help much, will be looking forward for more informative post than this. Will suggest some points that are to the best of my knowledge. This might help you bringing more information for all of us.
12/13/2010 5:08:13 AM #
Hey, I just forwarded this to some friends, loving it! Smile

Regards!


12/13/2010 5:32:47 AM #
You are a very capable person!
12/13/2010 6:29:50 AM #
lol a couple of the reviews bloggers write are silly and unrelated, there are times i wonder whether they at all read the post before writing or whether they just look at the subject of the blog post and compose the very first thought that drifts to their minds. But it is great to see a intelligent commentary every now and then in contrast to the exact same, traditional blog bull which I too many times notice on the blogs. Regards PokemonCraft Admin.
12/13/2010 7:10:21 AM #
great page how can we contact you to help us improve our sites. http://greenpois0n.co.uk and http://www.nightclub.org.uk
12/13/2010 8:00:23 AM #
I'm so done of coming to a web page to remark and finding spam remarks. Can't they uncover anything wiser to do with their time spent?
12/13/2010 10:01:31 AM #
Hi there I like your post interesting article. Were did you got all the information from...
12/13/2010 11:08:36 AM #
Hey, just looking around some blogs, seems a fairly nice platform you are using. I'm presently using Wordpress for a few of my web sites but looking to alter 1 of them more than to a platform similar to yours as a trial run. Something in specific you'd recommend about it?
12/13/2010 11:45:11 AM #
Nice website.
12/13/2010 12:39:31 PM #
You now what? You should be God or something else! Fantastic blog!
12/13/2010 12:46:07 PM #
Hello.This article was extremely remarkable, especially since I was searching for thoughts on this topic last Friday.
12/13/2010 1:04:39 PM #
Hello. Great job. I did not anticipate this. This is a splendid story. Thanks!
12/13/2010 2:07:20 PM #
Awesome post . Thanks for, posting on this blog mate! I'll email you again! I didn't know that.
12/13/2010 4:22:55 PM #
Great info! check it here: http://www.tv-online-live.com  - you can watch tv online!
12/13/2010 7:23:19 PM #
they were showing pamela on tv the other day and she looks so old and bulky now. not the hot baywatch babe anymore
12/13/2010 9:50:26 PM #
You really know how to keep a post interesting. Thank you very much.
12/13/2010 10:27:49 PM #
Hi. I just noticed that your site looks like it has a few code problems at the very top of your website's page. Is it an older version of blogengine.net?  I'm not sure if everybody is getting this same bugginess when browsing your blog? I am using a totally different browser than most people, referred to as Chrome, so that is what might be causing my problem? I just wanted to make sure you knew. Thanks for posting some great postings and I will try to return back with a completely different browser to check things out!
12/13/2010 10:29:46 PM #
sure, I like this web-site, always something usefull, propecia
12/13/2010 10:31:32 PM #
How do you make a site look this cool! Email me if you want and share your wisdom. I'd be appreciative!
12/13/2010 10:43:11 PM #
I  liked your article. I think I am going to have to subscribe.And great Topic.
12/14/2010 12:36:35 AM #
I absoultely that this article is the best piece of work that i've ever read in my life.
12/14/2010 1:15:12 AM #
I'm getting a browser error, is anyone else?
12/14/2010 1:41:37 AM #
Very good post. The search engines should rank you higher, even though I found you on page 3. Anyways I like it so keep it up. Please visit my Smile. Thank you!
12/14/2010 2:11:26 AM #
Interesting articles I am honered to have reding
12/14/2010 2:52:18 AM #
I  admired your article. I think I am going to have to subscribe.And good Topic.