You can edit HTML content in two ways: change the source file and reload the page, or let visitors edit text directly in the browser with the contenteditable attribute. You can also mark up edits in a document with the semantic <ins> and <del> elements.
This tutorial covers all three, with small examples you can paste into an index.html file.
The normal way to change a page is to edit its source and refresh the browser.
.html file in a code editor such as Visual Studio Code.<p> element.A live-reload tool such as the Live Server extension, or the dev server of your framework, refreshes the browser automatically each time you save.
The global attribute contenteditable lets a visitor type directly into an element.
Edits exist only in the page in memory. Reloading the page discards them, so to keep the changes you must read the content with JavaScript and send it somewhere.
This stores the text in localStorage in that browser. For real applications, send it to a server and sanitize any HTML you accept.
You can try changes on any page without touching its files:
document.designMode = "on" in the console to make the whole page editable.These changes disappear on reload and never affect the real site. It is a quick way to test layout and wording.
HTML has semantic elements to show that content was added or removed. Browsers underline <ins> and strike through <del> by default.
The optional datetime attribute records when the change happened, and cite can point to a document that explains it. Use these elements for visible revision history, not as a general way to style text.
For non-technical editors, a content management system or a rich-text component saves HTML for you. Keep these points in mind:
<div> elements.Any plain-text editor works. Visual Studio Code is a popular free choice with HTML completion, formatting and a built-in live preview through extensions.
The browser may be showing a cached copy or you may have edited a different file. Do a hard refresh (Ctrl+Shift+R) and confirm the file path.
No. It only allows typing in the page. You need JavaScript to read the content and store it in localStorage or send it to a server.
Not without sanitizing it. Untrusted HTML can include scripts, so clean it with a trusted sanitizer on the server before storing or showing it.
Edit the source file and reload to change a real page, use contenteditable for in-browser editing that you save with JavaScript, use DevTools for throwaway experiments, and use <ins> and <del> to show revisions. Always sanitize content that comes from users.