Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to have multiple html, head, and body elements in single page

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.

like image 860
nicknisi Avatar asked Apr 08 '10 20:04

nicknisi


2 Answers

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.

like image 173
Philip Daubmeier Avatar answered Nov 04 '22 20:11

Philip Daubmeier


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.

like image 22
Etamar Laron Avatar answered Nov 04 '22 21:11

Etamar Laron