views:

73

answers:

3

I have multiple pages being pulled together into a single page. Some of these individual pages have their own html, head, and body elements. Is it detrimental to the performance of the page to have these? It seems that the DOM is correct (only has a single of each element) in FireBug.

A: 

Having more than one html, head or body is anyway detrimental to your page's compliance to standards (be it HTML or XML), and should be avoided for that single reason.

Now about performance, this is more than likely to have your browser to use "quirks" mode and possibly get improper rendering for some elements under particular circumstances (or everything can be fine, but one shouldn't always rely on luck I guess).

Romain
+1  A: 

The DOM may be correct, but it is up to the web browser implementation to decide what to do in this situation. This is due to the situation being an "undefined state."

One option would be to discontinue digesting next occurances of the HTML, HEAD and BODY elements. Another (less favorable IMHO) would be to take into consideration only the last. But it is really up to the specific browser implementation (or web component) and how it is built.

Etamar L.
+2  A: 

First: don't do that.

Browsers are very tolerant if it comes to parse HTML, therefore firefox has a valid DOM in your case. Having multiple html, body and head tags does not affect the performance of the page parsing. But be aware that the browser will propably run in a quirks mode and affect the rendering of any of your elements.

Anyways this is totally against any standards and you should avoid producing such pages. Some browsers could possibly reject to display anything of your site. That may be some browsers you havent thought of, a text browser, or a lightweight browser on a older mobile phone for example.

Philip Daubmeier
Thanks for the response.
nicknisi