While I know wrapping a paragraph inside a heading like this:
<h1><p>Lorem<br>Ipsum</p></h1>
is invalid (see this question for example), it still renders correctly in all major browsers.
But as soon as I load the page inside an iFrame, it does break up the heading like you would usually expect the browser to do, rendering something like this:
<h1></h1><p>Lorem<br>Ipsum</p>
Why does that behave differently in an iFrame?
2
Answers
In fact the problem is not the iFrame, but the PHP proxy supplying the iFrames content. I forgot that I included HTML parsing in that proxy to be able to inject a custom base tag and CSS.
This proxy uses
DOMDocument
sloadHTML
andsaveHTML
methods which seems to convert the content to valid HTML.So it's not the browser being incosistent, it's due to the proxy.
Here’s a simple example below:
Main HTML Document:
Embedded in Iframe:
iframe-content.html: