I have a contenteditable div with ul and some li in it. Now, if I want to add some more text behind the list, I place the cursor after the last li ("3") and paste it twice. After the first input, he adds a new li, and after the second input, he closes ul and adds a div with br inside it so that I can start writing in it. ( Example # 1 )
Expected Code:
<div contenteditable="true"> <p>Test</p> <ul> <li>1</li> <li>2</li> <li>3</li> </ul><div><br></div> </div>
This is the expected behavior. But if there are some style sheets for li, the browser not only adds a new div with br, but also adds different code according to the styles you defined ( Example # 2 ).
Resulting Code:
<div contenteditable="true"> <p>Test</p> <ul> <li>1</li> <li>2</li> <li>3</li> </ul><div><font face="Arial"><span style="line-height: 20px;"><br></span></font></div> </div>
What can I do to prevent this browser behavior? I want to have some stylesheets for li, but I donβt want the browser to insert whatever it likes in my html code.
source share