After stumbling upon this bugzilla thread, I did a quick little test.
It appears that the <br>
tags is inserted because you're setting a <div>
(block) as contentEditable. I think it's automagically inserted to prevent the element from collapsing.
If you do the same thing with a <span>
(inline) element, CSS-stylized with a
display: block;
min-height: xxx px; // To prevent collapsing when empty
then you're set, no more <br>
inserted, and the element won't collapse.
Link to the demo JSFiddle
PS: I did check only under Firefox. If I remember correctly, there was a bug on the old WebKit engine where you couldn't place the caret in an empty node, you might encounter it.
` is all that exists, remove it. – Wes Foster Aug 04 '16 at 14:34
tag after deleting all content – murli2308 Aug 04 '16 at 14:37