In this lesson we explore localStorage and <iframe> in HTML5.
localStorage
lets you store data directly in the browser using a key–value system. Unlike cookies, it doesn’t expire automatically and is not sent to the server. Common methods are:
-
localStorage.setItem(key, value)
to store data -
localStorage.getItem(key)
to read data -
localStorage.removeItem(key)
to delete one key -
localStorage.clear()
to wipe everything
It’s useful for remembering things like usernames, preferences, or page settings across visits. Values persist even after reloading or closing the browser, until they’re removed.
The <iframe> tag lets you embed another webpage inside your page. Attributes like src
, title
, width
, height
, and loading="lazy"
help control behavior and accessibility. Some sites block embedding for security reasons, so not all URLs will work inside an iframe.
Together, these features give developers tools to store client-side data and to embed outside content.