Create Html Editor

html-editor
<div id="editor"></div>
<script>
    var editor = document.getElementById("editor");
    editor.contentEditable = true;
    editor.innerHTML = "Type your HTML here...";
</script>

This creates a content-editable div element with the ID “editor”, and sets its innerHTML to the text “Type your HTML here…”. The user can then edit the contents of the div as if it were a simple text area, and the changes will be saved as HTML.

You can add some buttons to save and clear the contents of the editor and also to perform some basic formatting like making text bold,italic, and underline

<div id="editor"></div>
<button onclick="bold()">Bold</button>
<button onclick="italic()">Italic</button>
<button onclick="underline()">Underline</button>
<button onclick="save()">Save</button>
<button onclick="clear()">Clear</button>

<script>
    var editor = document.getElementById("editor");
    editor.contentEditable = true;
    editor.innerHTML = "Type your HTML here...";

    function bold() {
        document.execCommand('bold', false, null);
    }
    function italic() {
        document.execCommand('italic', false, null);
    }
    function underline() {
        document.execCommand('underline', false, null);
    }
    function save() {
        var html = editor.innerHTML;
        // save html to localStorage or send to server
    }
    function clear() {
        editor.innerHTML = '';
    }
</script>

This is a basic example and you can add more functionality and styling to make it more user-friendly.