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
2.2k views
in Technique[技术] by (71.8m points)

why we use <html> tag although my website runs perfect without <html> tag

I need to know what is the use of <html> tag from the beginning of the webpage although website runs perfectly without these <html> </html> tags.

I knew that doctype is required but why this <html> tag is required.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

The <html> tag is not required.

From the DTD:

<!ELEMENT HTML O O (%html.content;)    -- document root element -->

The two Os indicate that the start and end tags (respectively) are optional.

The element, on the other hand, is required (but the language is designed so that browsers can imply it).

Since a DOM consists of a tree of nodes, you have to have one node (the root element) for everything else to hang from, and that is the html element.

It is also a really useful place to stick a lang attribute that will apply to the entire document.


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

...