HTML5 storage is a label rather than a specification. It became common around the time the HTML5 effort introduced browser features for keeping data on the client beyond what cookies could hold, and it is still used loosely for any of them. At its core the phrase means the Web Storage API, which gives page scripts direct access to small key/value stores, through two objects: localStorage and sessionStorage. In wider use it also sweeps in IndexedDB, a transactional database for structured data, and the Cache API used by service workers. These are separate APIs with separate rules, and the most useful thing an explanation can do is take the umbrella apart and show what each part stores, for how long, and for whom.
The Web Storage Interface
The Web Storage API exposes a simple interface. A Storage object holds string keys mapped to string values, and a script reads and writes them through methods such as setItem, getItem, removeItem and clear. Values are strings, so anything structured is serialised, usually as JSON, before it is stored. Access is synchronous: a call blocks until it completes, which is convenient for small reads and a problem for large or frequent ones, which is why MDN points developers toward IndexedDB when performance or dataset size matters.
Origin is the basic storage boundary; browsers can add partition keys for embedded third-party contexts. Every origin, meaning the combination of scheme, host and port, gets its own separate storage area, and documents from one origin cannot read another's. Third-party code behaves according to how it is embedded: a script tag runs in the embedding page's context and writes to the embedder's storage, while an iframe writes to its own origin's storage. Browser privacy settings may deny or partition third-party storage, so cookie blocking does not imply one universal storage policy. A storage event notifies other documents sharing the affected storage area. For localStorage this can include other same-origin tabs in the same partition; for sessionStorage it is limited to the same top-level browsing context.
localStorage and sessionStorage
The two objects share the interface and differ in scope and lifetime.
| Property | localStorage | sessionStorage |
|---|---|---|
| Partitioned by | Origin, with additional partitioning in some embedded contexts | Origin and browser tab |
| Shared between tabs | Yes within the same origin and storage partition | No, each tab has its own area |
| Lifetime | Persists after the browser is closed and reopened | Associated with the tab session; restoration can preserve it |
| Private browsing | Temporary; normally cleared when the private session ends | Cleared when the tab or window closes |
| Typical use | Preferences, cached state, feature flags | Form progress, per-tab navigation state |
MDN's quota page states that Web Storage is limited to a maximum of 10 MiB across browsers, with up to 5 MiB of local storage and 5 MiB of session storage per origin, and that exceeding the limit throws a QuotaExceededError that code should catch. The practical consequence is that localStorage and sessionStorage suit small amounts of state, not documents or media.
Persistence is less absolute than the name localStorage suggests. The browser clears the area when the user clears site data, and Safari proactively deletes script-created storage for an origin that has had no user interaction in the last seven days of browser use while cross-site tracking prevention is on, with server-set cookies exempt. Storage pressure can also trigger eviction, though browsers apply that to the larger managed stores rather than to Web Storage specifically.
Web Storage Compared With IndexedDB, Cache and Cookies
The browser storage types that share the HTML5 umbrella answer different needs.
- IndexedDB stores structured records and binary values, with indexes for finding records without scanning the entire collection. It is transactional and asynchronous and follows the same-origin policy. Where Web Storage stores strings, IndexedDB stores supported structured-clone values and binary data, which is why offline-capable applications use it.
- Cache API stores HTTP request and response pairs, typically populated by a service worker so that a site can serve pages and assets without a network. It is a cache of responses, not a general key-value store.
- Cookies are sent to the server with every matching request, are limited to a few kilobytes each, and carry attributes governing transport, script access and cross-site sending. Web Storage never leaves the browser unless a script sends it, so sending it requires application code. It does not offer HttpOnly protection and is a poor place for session secrets that should remain inaccessible to page scripts.
Storage quotas differ sharply. The larger stores are governed by a browser-managed quota system; MDN records that Chromium-based browsers allow an origin up to 60 percent of total disk, Firefox the smaller of 10 percent of disk or a 10 GiB group limit in best-effort mode, and Safari around 60 percent of disk for browser apps, with the usual least-recently-used eviction under storage pressure for origins that have not been granted persistence. Those figures are browser-specific and change between versions, so code should query the Storage Manager estimate rather than assume a number.
Where Each Store Is Used
A settings panel writes a theme choice to localStorage so it survives restarts. A multi-step form keeps its draft in sessionStorage so a refresh does not lose it. A separately opened tab has its own area, although a tab created with an opener may initially receive a copy of the opener's sessionStorage. A mail client stores message bodies in IndexedDB for offline reading. A progressive web app precaches its shell in the Cache API. An analytics script stores a first-party visitor identifier in localStorage as a fallback when cookies are unavailable, which is one reason clearing cookies alone does not reset such identifiers. Automation and testing tools inspect and seed these stores to reproduce application state, and browser profiles that isolate storage per profile keep one site's localStorage from another profile's.
Limits of the Umbrella Term
Because HTML5 storage names a family rather than one API, statements about it are often wrong for some member. Only Web Storage is synchronous and string-only; only sessionStorage is per-tab; IndexedDB offers indexed structured records, while the Cache API can also retain binary response bodies; only cookies travel to the server automatically. Quotas, eviction and private-browsing behaviour are set per browser and should be checked for the specific browser and version in question. Web Storage, IndexedDB and the Cache API are accessible to eligible scripts in their storage context; they do not provide HttpOnly isolation. Cookies with HttpOnly are an important exception. User clearing, browser policies and possible eviction mean important local data needs a recovery or export plan, whether it can be rebuilt from a server or was created only on the device.