开发者

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.


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.


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜