You can do this with the contentEditable propertiy div element. Say you have a bold button. The user clicks on it, then you call the js function and open the tag, for example, <b> , when the user clicks on a regular button, you close it. Same thing with color. Open <span style="backround-color:red"> .. You basically create div text with js .. Try jquery for easy house manipulation.
source share