Skip to: content, navigation

by Ian Lloyd

html (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

This example shows the html element surrounding all elements in a document:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Page title goes here</title>
  </head>
  <body>
    <!-- content goes here -->
  </body>
</html>
Type
structural element
Contains
head, body or frameset
Contained by
nothing; this is the parent element for all HTML elements

Description

The html element is the outer container for everything that appears in an HTML (or XHTML) document. It can only contain two elements as direct descendants, namely the head element and either a body or frameset element. It can also contain comments. As it is the outermost element in the document, it’s also known as the root element.

Note that the xmlns is required for XHTML page , but is invalid in HTML pages.

Although the html element is the outermost element, it does not contain the doctype—the doctype must come before the html element.

Use This For …

This element will have a place on every single web page you ever create! There’s no case in which you would not use this element when crafting a web page.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Every browser listed supports this element type.

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters