Search code examples
htmlsemantic-markup

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?


Solution

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