Science, Tech, Math › Computer Science Learn How to Set Web Page Content As Editable for Site Visitors Using the Contenteditable Attribute Share Flipboard Email Print Jamie Jones / Getty Images Science, Tech, Math PHP Programming Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Jennifer Kyrnin Jennifer Kyrnin Writer University of California University of Washington Jennifer Kyrnin is a professional web developer who assists others in learning web design, HTML, CSS, and XML. Learn about our Editorial Process Updated on February 11, 2020 Making the text on a website editable by users is easier than you might expect. HTML provides an attribute for this purpose: contenteditable. The contenteditable attribute was first introduced in 2014 with the release of HTML5. It specifies whether the content it governs can be changed by a site visitor from within the browser. Support for the Contenteditable Attribute Most modern desktop browsers support the attribute. These include: Chrome 4.0 and up Internet Explorer 6 and up Firefox 3.5 and up Safari 3.1 and up Opera 10.1 and up Microsoft Edge The same goes for most mobile browsers, too. How to Use Contenteditable Simply add the attribute to the HTML element you want to make editable. It has three possible values: true, false and inherit. Inherit is the default value, meaning that the element takes on the value of its parent. Likewise, any child elements of your newly editable content also will be editable unless you change their values to false. For example, to make a DIV element editable, use: Create an Editable To-Do List With Contenteditable Editable content makes the most sense when you pair it with local storage, so the content persists between sessions and site visits. Open your page in an HTML editor. Create a bulleted, unordered list named myTasks: Some taskAnother task Add the contenteditable attribute to the element: You now have a to-do list that is editable — but if you close your browser or leave the page, your list will disappear. The solution: Add a simple script to save the tasks to localStorage. Add a link to jQuery in the This example uses the Google CDN, but you can host it yourself or use another CDN if you prefer. At the bottom of your page, just above the tag, add your script: }); Inside the document.ready function, add your script to load the tasks into localStorage and get any tasks that were saved there previously: localStorage.setItem('myTasksData', this.innerHTML); // save to localStorage});if ( localStorage.getItem('myTasksData')) { // if there is content in the localStorage$("#myTasks").html(localStorage.getItem('myTasksData')); // put content on page} }); The HTML for the entire page looks like this: My TasksEnter items for your list. The browser will store it for you, so that when you reopen your browser, it will still be here.Some taskAnother task Cite this Article Format mla apa chicago Your Citation Kyrnin, Jennifer. "Learn How to Set Web Page Content As Editable for Site Visitors." ThoughtCo, Sep. 30, 2021, thoughtco.com/making-content-editable-by-users-3467988. Kyrnin, Jennifer. (2021, September 30). Learn How to Set Web Page Content As Editable for Site Visitors. Retrieved from https://www.thoughtco.com/making-content-editable-by-users-3467988 Kyrnin, Jennifer. "Learn How to Set Web Page Content As Editable for Site Visitors." ThoughtCo. https://www.thoughtco.com/making-content-editable-by-users-3467988 (accessed June 5, 2023). copy citation