HTML < html> Tag: Definition, Usage, and Attributes

Understanding the HTML: Hypertext Markup Language <html> Tag

HTML < html> Tag

{tocify} $title={Table of Contents}

The HTML “<html> tag” is the top-level container element that defines the beginning and end of an HTML document. 

It is a required tag that encloses all other HTML tags, including the <head> and <body> sections, and it indicates that the content that follows will be written in HTML code.

The <html> tag is the first tag that appears in an HTML document, and it contains two main sections: the <head> section and the <body> section. 

The <head> section provides metadata about the document, such as the page title and links to external resources, while the <body> section contains the main content of the document, such as text, images, and multimedia elements.

The <html> tag supports the lang and dir attributes, which are used to specify the primary language used in the document and the directionality of the text, respectively. 

These attributes are used for accessibility and localization purposes and can be used together or separately depending on the needs of the document.

Overall, the <html> tag is a foundational element in HTML markup and is required in every HTML document. It serves as the container for all other HTML tags and defines the structure of the document.

<html> Tag: Definition, Usage, and Attributes

Definition 

The HTML (Hypertext Markup Language) <html> tag defines the beginning and end of an HTML document. 

It is the first tag that appears in an HTML document and indicates that the content that follows will be written in HTML code. 

The <html> tag contains two main sections: the <head> section, which provides metadata about the document, such as the page title and links to external resources, and the <body> section, which contains the main content of the document, such as text, images, and multimedia elements. 

All other HTML tags are nested within the <html> tag, and the closing </html> tag marks the end of the HTML document.

usage

The “<html>” tag is a required tag that must be included in every HTML document. 

It is the top-level container element that contains all other HTML tags, including the “<head>” and “<body>” sections. 

Here is an example of how the <html> tag is used in an HTML document:

<!DOCTYPE html>
<html>

<head>
<title>My HTML Page</title>

<meta charset="UTF-8"> </head>

<body>
<h1>Welcome to my HTML page</h1>
<p>This is a sample paragraph of text.</p>

 <img src="image.jpg" alt="A sample image"> 

</body>
</html>{codeBox}

In this example, the <html> tag is the first tag that appears, and it encloses the entire document. 

The <head> section contains metadata about the document, such as the page title and character encoding, and the <body> section contains the main content of the document, including headings, paragraphs, and images. 

All of these tags are nested within the <html> tag, and the closing </html> tag marks the end of the document.

Attributes

The <html> tag supports the following attributes:

  • lang: Specifies the primary language used in the document using a two-letter language code. This attribute is used for accessibility and localization purposes.
  • dir: Specifies the directionality of the text, either left-to-right (dir="ltr") or right-to-left (dir="rtl"). This attribute is used for languages that are written in a different direction than English.

Both the lang and dir attributes are optional but recommended for all HTML documents. 

They provide essential information to assistive technologies and search engines, and they can help ensure that content is displayed correctly for users who speak different languages or read from right to left.

Here is an example of how to use the “lang” and “dir” attributes in an <html> tag:

<html lang="en-US" dir="ltr">
  ...
</html>{codeBox}

In this example, the lang attribute specifies that the document is written in US English, and the dir attribute specifies that the text direction is left-to-right. 

Note that the lang attribute can also include a country or region code, such as en-GB for British English.{alertSuccess}

Conclusion:

Friends, according to my expertise, I have written complete information to help you with “HTML <html> Tag” If this post is favourable for you or not, please tell me by commenting.

If you liked this post, do not forget to share it with your friends so they can get information about it.

You can ask us through comments if you still have questions or doubts, I will answer all your questions, and you can contact us for more information.

Please tell us through the comment section if you think we miss anything.

To be published, comments must be reviewed by the administrator.*

Previous Post Next Post