See the demo http://nmanikiran.github.io/designEditor/
https://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla https://developer.mozilla.org/en-US/docs/Web/API/document.execCommand https://blog.whatwg.org/the-road-to-html-5-contenteditable