Skip to content

Instantly share code, notes, and snippets.

@DuncanWilder
Last active April 20, 2023 15:42
Show Gist options
  • Save DuncanWilder/da3ac67ad4ac726d0a63 to your computer and use it in GitHub Desktop.
Save DuncanWilder/da3ac67ad4ac726d0a63 to your computer and use it in GitHub Desktop.
Pressing enter/return on a contenteditable div places this into the html
contenteditable
Pressing enter/return on a contenteditable div places this into the html
Fix: http://jakiestfu.github.io/Medium.js/docs/ or http://stackoverflow.com/questions/18552336/prevent-contenteditable-adding-div-on-enter-chrome
Firefox: <br>
Chrome: <div><br></div> (<div>With text</div>)
Safari: <div><br></div> (<div>With text</div>)
IE11: <p><br></p> (<p>With text</p>)
IE10: <p>&nbsp;</p> (<p>With text</p>)
IE9: <p>&nbsp;</p> (<p>With text</p>)
IE also places a <p> tag around the prior element if it does not have one. So
<div>text</div>
becomes
<div><p>text</p><p>More text</p></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment