The <html>
tag is a container for the entire page.
The exeption is <!DOCTYPE>
, which must be the first line in a page.
This tag tells the browser that the current page is an HTML document.
An <html>
container with two child elements: <head> and <body>.
<!DOCTYPE html>
<html>
<head>
<!-- meta data -->
</head>
<body>
<!-- page content -->
</body>
</html>
Notice that !DOCTYPE is outside the <html>
container.
The <html>
element serves as a container for all HTML elements -- except <!DOCTYPE>
.
A page can only have one <html>
tag.
An <html>
container tag.
Nested inside are the <head> and <body> tags, which, in turn, have their own nested tags.
A paragraph on the page.
<!DOCTYPE html>
<html>
<head>
<title>Title of the page</title>
</head>
<body>
<h3>A page header</h3>
<p>A paragraph on the page.</p>
</body>
</html>
This table lists the <html>
tag attributes.
Attribute | Value | Description |
---|---|---|
xmlns |
http://www.w3.org/1999/xhtml | Specifies that the content conforms to XHTML formatting rules. Optional in HTML5 as it is the default. |
lang | language-code | Sets the language for the page. See our Language Codes Reference for a list of valid values. |
For additional global attributes see our global attributes list.
An <html>
tag that specifies an English web page.
<html lang="en">
.. content here ..
</html>
Tip: Be sure to include the lang attribute.
This will tell browsers, screen readers, and search engines the language of your page.
Do not use the attributes listed below. They are no longer valid on the html tag in HTML5.
Attribute | Description | Alternative |
---|---|---|
manifest |
Sets a URL with resources that should be cached locally. | n/a |
version |
Specifies the DTD (data type definition) version of the HTML. Redundant in HTML5 | n/a |
The <html>
tag is part of a group of tags that
define the structure of a web page.
This group is referred to as the Page tag group.
Together, they allow you to create solid, well-structured web pages.
Here is the complete list.
Element | Description |
---|---|
<!DOCTYPE> | Must appear on the first line of a page. Specifies the HTML version |
<html> | Defines the root container for an HTML document |
<head> | Creates a head container that holds page-level metadata elements |
<meta> | Provides metadata about a web page |
<link> | Defines a link to an external source, such as a style sheet |
<base> | Sets the base URL for all relative URLs on a page |
<script> | Adds JavaScript to a page. Either client- or server-side |
<style> | Adds CSS style elements to a page |
<title> | Specifies the page title that displays in the browser's tab |
<body> | Specifies a container for the content of the page, with text, links, images, etc. |
Here is when <html>
support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |