Web Storage in HTML 5
In the previous of HTML, cookies were used to store data on the client (Web browser). However, cookies were not suitable for storing large amount of data as it resulted in making the Web browser very slow and ineffective. Therefore, a new feature in HTML 5, Web storage has been introduced to solve this issue.
In HTML 5, the data is not stored on the Web browser on every request, but is saved only when asked for. With this new feature it is also possible to store large amount of data without having any effet on the performance of the website
Web Storage feature in HTML 5 uses 2 types of storage objects:
- localStorage: Refers to the objet that stores the persistent information on the client’s computer. The information stored using this storage does not need to be sent to the Web server. This object stores the data with no time limit, which implies that the user can retrieve the data after closing and re-opening of browser window.
- sessionStorage: Refers to the object in which the information can be stored only for the sessions as long as the browser window is open. As a user closes the browser window, data gets deleted. In case of sessionStorage, the data available at the first tab or window is not accessible in another tab or window.
You should note that Chrome 5, Firefox 3.6, Safari 4, Opera 10.5, IE8 provide support to localStorage, while sessionStorage is supported by all the browsers except in the older versions of Chrome.
Offline Application Caching
In the previous versions of HTML, the caching mechanism was not fully supported. For example, you are browsing through a website on your computer. Due to some network problem Internet stopes working. You click the Back button, hoping that you might be able to view the website. However, as you are not connected to the internet and also the Web browerser did not cache the page properly. The site does not load. You then click the forward button hoping that the current page might load, but this also does not work. You need to reconnect to the Internet to view the website.
This problem has, to some extent been solved in HTML 5. The offline application cahing feature of HTML 5 helps in loading the Web page correctly, even if you are offline. This feature can be implemented while a developer is building the website, using HTML 5. The developer can specify the files that the Web browser should cache, so that even if a user is offline, the Web page is loaded correctly.
- This feature of HTML 5 has the following advantages:
- Helps a user in browsing a website, even if the user is offline
- Helps in loading the files that are cached much faster
- Helps in reducing the load on the server
Error Handling
HTML 5 has been designed in a manner so that the browsers, which do not support HTML 5, can ignore the HTML 5 constructs and safety load a Web page. This feature of HTML 5 is termed as the error handling feature.this feature of HTML 5 also helps you in handling the errors found in the syntax of HTML while creating a document.
The HTML 5 specification also provides the rules of parsing (process of analyzing text) and lexing (process of converting a sequence of characters into a sequence of tokens) and so that different browsers will produce the same result in case of incorrect syntax.
After learning about the new features of HTML 5 in detail, let’s now learn about some basic concepts of HTML.