If you have the following HTML:
<div contenteditable="true">
<p>The first paragraph</p>
<p>The second paragraph</p>
</div>
Is there a way to style the paragraph that is being edited differently from all other paragraphs in the div
that is contenteditable
?
div > p:focus { border: 1px solid red }
won't be applied to the paragraph being edited.
Here's a JSFiddle you can play with.
How can I style the paragraph being edited (the <p>
-tag) differently?
I'd prefer a CSS-only solution, but perhaps I'll have to use JavaScript.
EDIT:
Since we could not find a pure CSS solution (and using :hover
is not a real solution for me) I am now looking for some lines of JavaScript that set the attribute class="focus"
on the node that is being edited.