HTML DOM Window localStorage Properties Last Updated : 25 Nov, 2021 Comments Improve Suggest changes 1 Likes Like Report HTML DOM Window localStorage Properties allow you to store value pairs in web browsers using objects. It is a read-only property. This object is not expired even if the browser is closed. So, the data is never lost. Return Values: It returns  a Storage object. Syntax: SAVING data to localStorage using: localStorage.setItem("key", "value"); READING data from localStorage using: var name = localStorage.getItem("key"); REMOVING data from localStorage using: localStorage.removeItem("key"); Example1: This example describes the Save, Read and Remove data to localStorage. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM Window localStorage Properties </title> <script> //Saving data locally function save() { var fieldValue = document.getElementById('textfield').value; localStorage.setItem('text', fieldValue); } // Reading data function get() { var storedValue = localStorage.getItem('text'); if(storedValue) { document.getElementById('textfield').value = storedValue; } } // Removing stored data function remove() { document.getElementById('textfield').value = ''; localStorage.removeItem('text'); } </script> </head> <body onload="get()"> <p1> Type something in the text field and It will Get stored locally by Browser </p1> <input type="text" id="textfield" /> <input type="button" value="save" onclick="save()" /> <input type="button" value="clear" onclick="remove()" /> <p2> when you reopen or reload this page, your text is still there. </p2> <p3> <br>click on clear to remove it.</p3> </body> </html> Output: Window localStorage Example 2: This example describes the check storage type and saves data. HTML <!DOCTYPE html> <html> <head> <title>HTML DOM Window localStorage Properties</title> </head> <body> <div id="SHOW"></div> <script> if(typeof(Storage) !== "undefined") { localStorage.setItem("name", "GeeksforGeeks"); document.getElementById("SHOW").innerHTML = localStorage.getItem("name"); } else { document.getElementById("SHOW").innerHTML = "YOUR BROWSER DOES NOT" + "SUPPORT LOCALSTORAGE PROPERTY"; } </script> </body> </html> Output: Window localStorage Property Supported Browsers: The browser supported by DOM Window localStorage are listed below: Google Chrome 4.0Internet Explorer 8.0Microsoft Edge 12.0Firefox 3.5Opera 10.5Safari 4.0 Create Quiz Comment A AkshayGulati Follow 1 Improve A AkshayGulati Follow 1 Improve Article Tags : Web Technologies HTML HTML-DOM Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like