Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

html - What content can be outside head and body tags?

This may seem like a weird question, but i'm building some script that reads HTML files and i'm dividing the content to 2, body and head and was wondering if there could be other content i might not know of?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The doctype declaration isn't exactly content in the sense of the word.

There isn't any content that is supposed to exist outside head and body (and in fact, any content that's meant to display should only exist inside body). Browsers can create some pretty wacky DOMs when you give them strange or invalid markup, however. Here's an example.

Also, head and body, in that order, are the only two possible children of html, the root element.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...