HTML <html> Tag

The <html> tag is a container for the entire page -- except for <!DOCTYPE> which always is the first line in an HTML document.

HTML Tag

Example

#

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.


Using <html>

The <html> tag tells the browser that the current page is an HTML document.

This element serves as a container for all HTML elements -- except <!DOCTYPE>.

A page can only have one <html> tag.

More Examples

An <html> container tag.
Nested inside are the <head> and <body> tags, which, in turn, have their own nested tags.

Title of the page

A page header

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>

Attributes for <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.


Obsolete Attributes

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

Page Tags

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, these tags 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.

Browser support

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

You may also like

Guides