What content may be outside the head and body tags?

This may seem like a strange question, but I create a script that reads HTML files and I split the content into 2, body and head and wonder if there could be other content that I donโ€™t know from?

The only thing I know is <DOCTYPE> , and I was wondering if there could be more?

+4
source share
1 answer

The doctype declaration does not exactly match the meaning of the word.

There is no content that should exist outside the head and body (and in fact, any content that should be displayed should exist only inside the body ). However, browsers can create some pretty crazy DOMs when you give them weird or invalid markup. Here is an example.

In addition, head and body in this order are the only two possible children of the html , the root element.

+7
source

Source: https://habr.com/ru/post/1447183/


All Articles