I am trying to make an application to edit documents using contenteditable
. I would like to apply a :focus state to an element, like this:
.focus:focus {
color: red;
}
However, this doesn't appear to work when the element is nested in another contenteditable element. If I have some html like this, it works:
<span contenteditable class="focus">content</span>
But if I do something like this, it doesn't work:
<div contenteditable>
<span contenteditable class="focus">content</span>
</div>
For the purposes of how I am using this, I need the outer contenteditable element. I would prefer to use css only for this. Is there a workaround for this?