/ factorpad.com / tech / html5 / reference / html-html-tag.html
An ad-free and cookie-free website.
Beginner
The <html>
tag is one of
several important tags the developer places at the beginning of an
HTML document.
The <html>
tag is the root element,
which means that all other tags (elements) are contained within its
opening tag <html>
and
closing tag </html>
. So one
pair per document.
The <html>
tag is normally the second
line of the document, found right after the
<!DOCTYPE>
declaration.
The html
tag is not technically
required, as long as the first line is not a comment. However, in almost
all HTML documents the <html>
opening and closing tags are present.
While a closing <html>
tag is not
required, it should be used. In addition, within the opening and
closing tags, there should be a <head>
and <body>
element.
As with all tags, Global Attributes can always be set.
One such global attribute, the lang
attribute is used to specify the language of the document.
As an example, <html lang="es">
specifies a document written in Spanish.
Below are the 10 most common language codes.
Language | ISO 639-1 Code |
---|---|
Arabic | ar |
Chinese | zh |
English | en |
French | fr |
German | de |
Indonesian | id |
Japanese | ja |
Portuguese | pt |
Russian | ru |
Spanish | es |
If a lang
attribute is not specified,
it is inherited from its parent element. The rationale for why it is
specified in the first tag becomes clear. The smart developer can save
time by specifying the language just once, right at the start.
Each user-agent (browser) has its own stylesheet per se. This dictates
how that browser styles each element by default. The Chrome browser
styles the <html>
element using
the following specifications.
The following code establishes an HTML document with English as the written language.
The developer can specify whether a document is also written for XML, which is similar to HTML. This specifies that the document conforms to both markup languages. You wouldn't hear me say it, but these are also referred to as polyglot documents.
The <html>
tag is paired
with other essential tags that should be included in every HTML
document.
Pair this web content with videos at our YouTube Channel. Follow @factorpad at Twitter for updates.
<hr>
tag, click Back.<link>
tag, click
Next./ factorpad.com / tech / html5 / reference / html-html-tag.html
A newly-updated free resource. Connect and refer a friend today.