When you put <p><div></br></div></p>
into body, you will get the strange DOM structure like:
<p></p>
<div></br></div>
<p></p>
Why does this happened? It seems that when <p>
contains a block element this will happen.
According to the spec, p
cannot have nested block elements, so the HTML parser automatically closes it before the div
when building the DOM.
p
cannot hold a div
as it's a block
level element, p
can only hold inline
elements, so what you are trying is incorrect.
You can use span
instead and use display: block;
or display: inline-block;
in your CSS which will give you same effect and also it is completely acceptable as p
can hold a span
as it's an inline
element.
` tag?
– Kobi Aug 21 '13 at 07:24