Why is this "<p> <div> <br> </div> </p>" shown strange in the DOM?
2 answers
According to the specification, p cannot have nested block elements , so the HTML parser automatically closes it before the div when creating the DOM.
+8
p cannot contain a div as an element of the block level, p can only contain inline elements, so what you are trying is wrong.
Instead, you can use span and use display: block; or display: inline-block; in its CSS, which will give you the same effect, and is also quite acceptable, since p may contain a span , since it is an inline element.
+3