Search code examples
htmlxhtmltagsbrowserquirks-mode

Why does content placed after `</html>` show up in the browser?


I attempted to store some text that I might use later after the </html> tag of my document (like I routinely do with \end{document} in LaTeX) but the browser still shows the text.

It was my understanding that the page is defined by what is between <html> and </html>, so why do things beyond </html> get displayed?


Solution

  • This is because browsers try very hard to do the right thing with malformed markup. The solution is to only create well-formed documents.

    If you really want to store cruft in your document, place it in an xml/sgml comment: <!-- this is a comment -->