Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is how browser (HTML parser) works, since <code>&lt;div&gt;</code> is a <a href="http://dev.w3.org/html5/markup/common-models.html#common.elem.flow" rel="nofollow">Flow element</a> and <code>&lt;p&gt;</code> is a <a href="http://dev.w3.org/html5/markup/common-models.html#common.elem.phrasing" rel="nofollow">Phrasing element</a>, in most case an phrasing element cannot contain any flow element, this is called <strong>misnested tags</strong>, HTML parser would fix these issues magically with some certain steps: </p> <ol> <li>When reading <code>&lt;p&gt;</code>, it generates a <code>&lt;p&gt;</code> element</li> <li>When reading <code>&lt;div&gt;</code>, since <code>&lt;div&gt;</code> cannot reside in a <code>&lt;p&gt;</code> element, HTML parser closes the last <code>&lt;p&gt;</code> element, then open an <code>&lt;div&gt;</code> element</li> <li>When reading <code>&lt;/div&gt;</code>, closes the <code>&lt;div&gt;</code> element</li> <li>When reading <code>&lt;/p&gt;</code>, since previous <code>&lt;p&gt;</code> element is closed, parser recogonizes it as a <strong><code>&lt;p&gt;</code> element missing a start tag</strong>, so parser automatically inserts an <code>&lt;p&gt;</code> start tag here to create a complete <code>&lt;p&gt;</code> element</li> </ol> <p>Thus, the final DOM construct is:</p> <pre><code>&lt;p id="test"&gt;&lt;/p&gt; &lt;!-- auto closed --&gt; &lt;div&gt; box1 &lt;div&gt; box in box1 &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;!-- auto generated --&gt; </code></pre> <p>It's obvious that the <code>&lt;div&gt;</code> and <code>&lt;p&gt;</code> is at the same level, not forming a containing relation, so delegate fails here.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload