tags:

views:

124

answers:

4

Hello,

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.

+13  A: 

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.

David Dorward
This is true for HTML, but not for XHTML, since a root element is required for any valid XML document.
Daniel Pryden
The root element is still required for HTML, the tags are just optional. XML doesn't have optional tags though. (The question didn't mention XHTML though, so I didn't bring it up)
David Dorward
+1 for this answer. I wasn't aware about this "The <html> tag is not required." but will that page can pass w3c validation if page is not having `<html>`?
metal-gear-solid
Of course. It would be a pretty poor validator if it didn't understand the O in the DTD.
David Dorward
+3  A: 

You don't have to use it, it's optional:

7.3 The HTML element

Start tag: optional, End tag: optional

Source: http://www.w3.org/TR/html401/struct/global.html#h-7.3

Anax
A: 

It is optional tag, but some browsers add it to page, when you are browsing.

Pirozek
A: 

generally it works but when we have to give some arguments like html vesion any encryption then these are followed through tag

sagar
The closest thing we have to a way to specify the HTML version is the Doctype Declaration, which appears at the top of the document before any tags. Encryption on the web is handled on the transport layer, not the document layer, so that isn't impacted by the presence (or lack) of an HTML start tag (and no attributes on the HTML start tag are used for encryption).
David Dorward