HTML Tutorial

The language for building web pages.

HTML Web Storage

HTML Web Storage API

With web storage, web applications can store data locally within the user browser. Before HTML5, data had to be stored in cookies. Web storage is more secure, faster, and can store more data (5MB vs 4KB for cookies).

Two Types:

  • localStorage - Stores data with no expiration date. Data is NOT deleted when browser is closed.
  • sessionStorage - Stores data for ONE session. Data is deleted when browser tab is closed.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics