Posts Tagged ‘localstorage’

You all must have heard about HTML5 the new standards of markups.

HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).

WHATWG was working with web forms and applications, and W3C was working with XHTML 2.0. In 2006, they decided to cooperate and create a new version of HTML.

Some rules for HTML5 were established:

  • New features should be based on HTML, CSS, DOM, and JavaScript
  • Reduce the need for external plugins (like Flash)
  • Better error handling
  • More markup to replace scripting
  • HTML5 should be device independent
  • The development process should be visible to the public

It reduces the amount doctypes, encoding and meta tags on your webpage, have introduced lot of new markup tags such as <article>, <canvas>, <footer>, <Video>, geolocation etc. which makes your webpage source much more understandable for the search engines.

Also, It looks much more cleaner than the HTML4 / XHTML

HTML5 development is still under progress, and expected to be a public standard by 2020 or 2022.

Most of the latest browsers have started adding HTML5 support, however all the HTML5 tags are not available till date, Google Chrome supports most of the HTML5 tags, Firefox supports few and IE supports the least.

New tags are good, but the most userful feature in HTML5 I found is the local / web storage. It is a good replacement of browser cookies to store anything at client side.

One of the common disadvantage of cookie is that they are included with every HTTP request, thereby slowing down your web application by needlessly transmitting the same data over and over.

How to use localstorage in HTML 5:

Localstorage:

<script type=”text/javascript”>

localStorage.lastname=”Smith”;

document.write(localStorage.lastname);

</script>

Sessionstorage:

<script type=”text/javascript”>

sessionStorage.lastname=”Smith”;

document.write(sessionStorage.lastname);

</script>

Try this out, so far i have tested it on IE8, mozilla FF 4.0 & 5.0, Safari, Chrome, Opera and Rockmelt, they do support this local storage feature.

For more details on HTML5 and localstorage visit:

w3schools.com/html5/html5_webstorage.asp

diveintohtml5.org/storage.html

diveintohtml5.org

Advertisements