Wednesday, 29 June 2011

HTML5 and CSS3

Introduction
Even if more and more websites are starting to implement features of HTML5 since most modern browsers have some HTML5 support, this new standard for HTML, XHTML, and the HTML DOM is still a work in progress. 

Apart from the obvious of having new features based on HTML, CSS and JavaScript, the main aim of HTML5 is to reduce the need for external plugins (such as Flash) and scripting, have better error handling and perhaps most importantly (at least in my view) is to be independent from any device.



New Features in HTML5



Since the web has changed so much since the previous version of HTML released in 1999 HTML 5 introduces a lot of new features, to make better use of web capabilities. Some of the most noted features include:
  • Video and Audio Elements for media playback
  • More and better support for local offline storage which is based on databases instead of cookies
  • A canvas element for drawing used for rendering of graphics or other visual images
  • New form controls to be used for error handling
  • Content specific elements (such as: article, footer, header, nav and section) to give pages more meaning
  • New form controls ( such as : calendar, date, time, email, url, search) to be used instead of standard textboxes when a specific format of input must be done.




Browser compatibility 

Unfortunately browsers still don’t have a standard which all follow, each and every one of them have different compatibility with HTML5. A good way to find out how much your browser supports HTML5 is to go the website called html5test.com with any browser. This will give your browser a score out of 450 and then give you a detailed explanation where your browser gained an lost points on HTML 5 standard and specifications.

I first tested this website using the latest version of Google Chrome (12.0.742.112), this scored a respectable 328 (plus 13 bonus points) out of a possible 450, being highly compatible in the areas of Parsing rules, the Canvas element, Video (with the exception of subtitles and MPEG-4 support), Audio, Elements, User interaction, Geolocation, WebGL, Communication, and Storage, while having completely no support of microdata, local multimedia and notifications. Google Chrome fared reasonably in the Forms, Security and Files sections.

As a comperision Internet Explorer 9 only scores a 141 (with 5 bonus points) out of 450. Even the default browser of an Android smart phone scored a slightly better 184.





CSS 3


CSS 3 is the latest standard for CSS, which was developed to go with HTML 5 and has a lot of new features to be used to style Web pages.

The first feature that I have come across is the additional functionalities of borders. With CSS3, you can create rounded borders, add shadows to boxes and use images as borders. Unfortunately not all browser support all these features, and most that do require a prefix in order for everything to work.

Here is an example of a rounded border:





*here the –webkit- prefix is used for Google Chrome and Safari

Another interesting feature is the text shadow effect which is very simple to use, the only parameters to give are the horizontal shadow, the vertical shadow, the blur distance, and the color of the shadow.

text-shadow: 5px 5px 5px #FF0000;

 
CSS 3 has also added the capability to use fonts which are not installed on the user’s machine, but use a source with a URL.


A complete new feature is the 2D Transformations with which one can move, scale, turn ,spin and stretch elements.

-webkit-transform: rotate(30deg);
-webkit-transform: matrix(0.866,0.5,-0.5,0.866,0,0);
-webkit-transform: skew(30deg,20deg);
-webkit-transform: scale(2,4);
 
There are also the 3D transformations but these only work on Google Chrome and Safari using the –webkit- prefix

Another function is the Transition function which is used to add an effect when changing from one style to another without using Flash or JavaScripts.

This example would make a div element stretch whenever the user moved the mouse on it.







  
 







Finally there are also animations which can replace animated images, Flash animations, and JavaScripts in many web pages.

An example is to have the background color of an element change gradually, or the position change. This is done by writing what needs to happen at certain points of the animation, and how long would the animation take to fully complete.

For example an element starts off with a blue background color and you want it to animate to green midway through the animation and finally end up yellow. And you want the animation to last 10 seconds.
So in this case the CSS would be:









Conclusion

I found out that HTML 5 has amazing potential with all its features, unortunatly not all browsers are really compatible with it ubt progress is being made. I also think with all the features of HTML5 and CCS3, Flash and Javascript may die in the future.



No comments:

Post a Comment