JSFiddle - React, Tailwind, and code Playground
HTML
<div contenteditable><em>Edit me</em></div>
CSS
div{margin:14px}
div:focus{background:yellow}
em{font-style:italic;color:#888}
JavaScript
$('div').on('activate', function() {
$(this).empty();
var range, sel;
if ( (sel = document.selection) && document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}
});
$('div').focus(function() {
if (this.hasChildNodes() && document.createRange && window.getSelection) {
$(this).empty();
var range, sel;
range = document.createRange();
range.selectNodeContents(this);
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
});