html
  1. html-htmltag

HTML <html> Tag

The HTML <html> tag represents the root of an HTML document. It is the container for all other HTML tags.

Syntax

The basic syntax for the <html> tag is:

<!DOCTYPE html>
<html>
    <head>
        <title>Title of the Document</title>
    </head>
    <body>
        Content of the Document
    </body>
</html>

Example

<!DOCTYPE html>
<html>
    <head>
        <title>Welcome to My Website</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <p>Welcome to my website. Feel free to browse around!</p>
    </body>
</html>
Try Playground

The above HTML code will create a basic web page with a title of "Welcome to My Website" and a heading of "Hello World!".

Explanation

  • The DOCTYPE declaration specifies the version of HTML being used.
  • The opening and closing <html> tags define the beginning and end of the HTML document.
  • The opening and closing <head> tags define the section of the document that contains metadata and other HTML tags.
  • The <title> tag is used to specify the title of the document.
  • The opening and closing <body> tags define the section of the document that contains the content.

Use

The <html> tag is required in every HTML document and must be placed at the beginning of the document.

Important Points

  • The <html> tag should always be paired with a closing tag, </html>.
  • The <html> tag should be the first tag in an HTML document.
  • Proper indentation and code organization is important for readability and maintenance.

Summary

The <html> tag is the container for all other HTML tags and is required in every HTML document. It defines the beginning and end of an HTML document and contains the metadata and content of the document.

Published on: