<html> Tag Syntax
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet ...?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ... metadata content ... <title>My Title</title> ... metadata content ... </head> <body> ... flow content ... </body> </html>
Rules for coding the html element for HTML 5
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the <html> tag after the HTML DOCTYPE declaration at the beginning of the HTML document. To put common elements in templates that can be cached by browsers to speed up page load times, optionally include an xml-stylesheet instruction before the <html> tag.
- The tag's element type name is
html
. The name uses lower case letters and should be in the HTML namespace. - Indicate the namespace and HTML version by coding an xmlns attribute with a value of
"http://www.w3.org/1999/xhtml"
enclosed in double quotes. (For backward compatibility, the namespace from the 1999 W3C standard is used for all HTML versions from that year forward, including XHTML and HTML 5.) Aversion
attribute should not be coded. - Code a matching
</html>
end tag at the end of the document. - Between the starting
<html>
tag and ending</html>
tag, include a head element consisting of a starting <head> tag and ending </head> tag and a body element consisting of a starting <body> tag and ending </body> tag.
<html> Content Model
Contents of the <html> Tag
The html element typically contains the following child elements:
- a head element with metadata about the HTML document, and
- a body element with the content of the web page
possibly interspersed with HTML comments.