Why do newlines appear as spaces or disappear on Enter/Return key in Opera for contentEditable documents?
Try out this demo:
<!DOCTYPE html>
<html>
<head>
<title>contentEditable demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body contenteditable="true" spellcheck="true" dir="ltr">
<h1>Welcome to the contentEditable demo!</h1><p><span style="font-size: xx-large">
Try<span style="font-size: small">to type some text before the word "Try". You will see that random spaces are inserted before the word. Press Enter; you will see that the newline on the top disappears.</span></span></p></body>
</html>
Opera 11.50 Build 1074 on Windows Vista
Is this an Opera bug? I did not experience this bug with Windows Internet Explorer 8, Safari, Google Chrome, or Firefox 5.
I think that I may have discovered why from these links:
[whatwg] Handling of collapsed whitespace in contenteditable:
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-June/032187.html
Bug 13011 – [editing] Encourage authors to use “white-space: pre-wrap” for contenteditable=”” and .designMode=true:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=13011
Best practices for in-page editors:
http://developers.whatwg.org/editing.html#best-practices-for-in-page-editors