Introduction
This Article is exploring new features in HTML 5. Recently we heard a lot more about HTML 5, and it's features, advantages, and all other stuff. So, "What Does It All Mean??!!" - a common question we ask our self.
Let's get started exploring html5.
HTML was Born in late 1990, invented by Tim Berners-Lee(wiki link). He said "this is good" and proposed a draft to the Internet Engineering Task Force (IETF), a
standards organization. IETF drafts require implementations, so the HTML draft
referenced Mosaic, a web browser that later became Netscape, which later became
Firefox. Mosaic, of course, would have been rather worthless without HTML. So a
symbiosis between browsers and web standards drove the web from the beginning.
When the original HTML draft expired in 1994, the IETF created the first HTML
Working Group (HTMLWG), who created HTML 2. Also in 1994, Tim created the World
Wide Web Consortium (W3C), with a mission "To lead the World Wide Web to its
full potential by developing protocols and guidelines that ensure long-term
growth for the Web." If that sounds like what the HTMLWG was doing, that's because it was. The two standards bodies didn't run in parallel for long.
In 1996, after a series of additions to HTML 2, the IETF HTMLWG was closed and
further work on HTML moved to the W3C. The W3C published HTML 3.2 and HTML 4,
both in 1997. In December of 1999, HTML 4.01 was published.
In the seventh year (1998), the W3C rested. And rested. And rested. HTML hasn't changed since.
You may ask: "How can I start using HTML5 if older browsers don't support
it?" But the question itself is misleading. HTML5 is not one big thing; it is a
collection of individual features. So you can't detect "HTML5 support," because that doesn't make any sense. But you can detect support for individual features,
like canvas, video, or geolocation.
When your browser renders a web page, it constructs a Document Object Model
(DOM), a collection of objects that represent the HTML elements on the page.
Every element - every <p>, every <div>, every <span> - is represented in the DOM
by a different object. (There are also global objects, like window and
document,that aren't tied to specific elements.)
All DOM objects share a set of common properties, but some objects have more than others.
In browsers that support HTML5 features, certain objects will have unique properties. A quick peek at the DOM will tell you which features are supported.
There are four basic techniques for detecting whether a browser supports a
particular feature.
From simplest to most complex:
History of HTML
Get Started
Detection Techniques
- Check if a certain property exists on a
global object (such as window or navigator).
- function supports_geolocation() {
- return !!navigator.geolocation;
- }
- Create an element, then check if a certain
property exists on that element.
- function supports_canvas() {
- return !!document.createElement('canvas').getContext;
- }
- Create an element, check if a certain
method exists on that element, then call the method and check the value it
returns.
- function supports_h264_baseline_video() {
- if (!supports_video()) { return false; }
- var v = document.createElement("video");
- return v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
- }
- Create an element, set a property to a
certain value, then check if the property has retained its value.
- var i = document.createElement("input");
- i.setAttribute("type", "color");
- return i.type !== "text";
Canvas
- <canvas width="300" height="225"></canvas>
- <canvas id="a" width="300" height="225"></canvas>
- var a_canvas = document.getElementById("a");
- fillRect(x, y, width, height) draws a rectangle filled with the current fill style.
- The strokeStyle property is like fillStyle - it can be a CSS color, a pattern, or a gradient.
- strokeRect(x, y, width, height) draws a rectangle with the current stroke style. strokeRect doesn't fill in the middle; it just draws the edges.
- clearRect(x, y, width, height) clears the pixels in the specified rectangle.
Video
Anyone who has visited YouTube.com in the past four years knows that you can embed video on a web page. But prior to HTML5, there was no standards-based way to do this. Virtually all the video you've ever watched "on the web" has been
funneled through a third-party plugin - maybe QuickTime, maybe RealPlayer, maybe
Flash. (YouTube uses Flash.) These plugins integrate with your browser well enough that you may not even be aware that you're using them. That is until you try to watch a video on a platform that doesn't support that plugin.- <video src="pr6.webm"></video>
- <video src="pr6.webm" width="320" height="240"></video>
- <video src="pr6.webm" width="320" height="240" preload></video>
- <video src="pr6.webm" width="320" height="240" preload="none"></video>
- <video src="pr6.webm" width="320" height="240" autoplay></video>
- <script>
- function failed(e) {
- // video playback failed - show a message saying why
- switch (e.target.error.code) {
- case e.target.error.MEDIA_ERR_ABORTED:
- alert('You aborted the video playback.');
- break;
- case e.target.error.MEDIA_ERR_NETWORK:
- alert('A network error caused the video download to fail part-way.');
- break;
- case e.target.error.MEDIA_ERR_DECODE:
- alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
- break;
- case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
- alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
- break;
- default:
- alert('An unknown error occurred.');
- break;
- }
- }
- </script>
- <p>
- <video src="tgif.vid" autoplay controls onerror="failed(event)"></video>
- </p>
- <p>
- <a href="tgif.vid">Download the video file</a>.
- </p>
some Html5 points will be coming soon in the next articles...............

Dinesh BeniwalPosted Oct 21, 2011, 12:00 AM
Good start on HTML5 Dhaval.