Is it possible to have multiple html, head and body elements on the same page?

I have several pages that are combined into one page. Some of these separate pages have their own html, head, and body elements. Is it bad for page performance? It seems that the DOM is correct (has only one element) in FireBug.

+4
source share
3 answers

First: do not do this.

Browsers are very tolerant when it comes to parsing HTML, so firefox has a valid DOM in your case. Having multiple html, body, and head tags does not affect page parsing performance. But keep in mind that the browser will work in quirks mode and affect the rendering of any of your elements.

In any case, this is completely contrary to any standards, and you should avoid creating such pages. Some browsers may reject the display of any of your site. These may be some browsers that you did not even think about, a text browser or a lightweight browser on an older mobile phone, for example.

+7
source

The DOM may be correct, but the solution to this problem depends on the implementation of the web browser. This is because the situation is "undefined".

One option would be to stop digesting the following elements of the HTML, HEAD, and BODY elements. Another (less favorable IMHO) will only take into account the latter. But it really depends on the specific implementation of the browser (or web component) and how it is built.

+1
source

Having more than one html , head or body in any way harmful for your page to conform to standards (be it HTML or XML), and should be avoided for this single reason.

Now about performance, it is more than likely that your browser will use the "quirks" mode and may have received the wrong rendering for some elements in certain circumstances (or everything may be fine, but you don't always have to rely on luck, I think).

0
source

Source: https://habr.com/ru/post/1306402/


All Articles