开发者

Should there ever be anything between the end </body> tag and the end </html> tag

Is there ever an instance in which something should (or can?) be placed between the </body> and </html> tag? Or should they always be paired开发者_如何学运维?

I was reading the HTML5 spec, and it got me thinking about the basic structure of a page.

Are there any cases where anything can/should be placed after the </html> tag? It used to be gospel that documents started with just <html>, but <!doctype...> changed that. Would there ever be a reason to change that for the end of a document?


The <body> tag is optional since <frameset> can be used instead. Therefore, they are not always paired. White space can exist between the tags. Also, <body> can come before <head>.

Currently, anything after a closing </html> tag is generally considered inline text. Firefox and IE both render it.

The Document Type Definitions (DTDs) of each style hold the answers you seek.


No, not really. There's no reason to put anything after </html>. After all, you are defining an html document. The DocType was introduced because of inconsistencies in browser rendering.

As for after the body tag. I could one day see "foot" as a tag introduced to match the head at the top. The only thing that I can see it being used for would be javascript that is loaded after the document. Right now, that is just put right before the end of the body tag.


Some people like to put javascripts intended to run after the page has finished loading either at the very bottom of the body section or below the </body> tag. Really though there is no reason to do this if you are using jQuery, since the $(document).ready() function makes it moot.

No structural tags should be there however, and actually JS should be in the <head> section anyway.


Nothing can go after </html> nor between </body> and </html>.

On the other hand, bear in mind that HTML, HEAD and BODY are implied even if the tags don't exist, so an html document does not have to end with </html>.

Of course, browsers tend to try to guess what the author wanted rather than breaking on invalid markup, so yes, you can expect people putting something after </html>, because it does what they want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜