Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <h1>How to unintentionally create nested p elements using execCommand('insertHTML')</h1>
  <em>* indicates that the paragraph is the :first-child in its DOM tree level; red paragraphs indicate nested p elements</em>
  <div contenteditable="true">
    <p><br></p>
  </div>
  <button type="button">execCommand('insertHTML', undefined, "&lt;p&gt;1st inserted&lt;/p&gt;&lt;p&gt;&lt;/p&gt;")</button>
  <pre>
</pre>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers