Yahel
Yahel

Reputation: 37305

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?

Upvotes: 5

Views: 956

Answers (4)

Marcus Adams
Marcus Adams

Reputation: 53830

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.

Upvotes: 4

zvone
zvone

Reputation: 19352

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.

Upvotes: 0

smdrager
smdrager

Reputation: 7417

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.

Upvotes: 0

Armstrongest
Armstrongest

Reputation: 15409

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.

Upvotes: 0

Related Questions