html (HTML element)
| Depr. | Empty | Version |
|---|---|---|
| No | No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
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.
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>
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
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
Every browser listed supports this element type.
In this Section
- xmlns
declares the URI of the default namespace for a document. In XHTML documents this will always have the value http://www.w3.org/1999/xhtml