<html> Tag in HTML
The <html> tag is the root element of an HTML document. It serves as the container for all other HTML elements on the page, except for the <!DOCTYPE> declaration. It is a required tag and must be the first tag in an HTML document.
Key Points on <html> Tag:
- The <html> tag wraps the entire content of the HTML document.
- It must contain a <head> and a <body> tag.
- The <html> tag can include a lang attribute to specify the language of the document.
- The <html> tag is not closed with a slash in the start tag.
Syntax of <html> Tag:
Syntax Example
<html lang="en">
<head> ... </head>
<body> ... </body>
</html>
Example of <html> Tag in HTML:
This example demonstrates the usage of the <html> tag as the root of the HTML document.
Code Example
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
Output
Hello, World!
The <html> tag is essential for every HTML document. It must enclose the entire content, including the <head> and <body> tags. It defines the language of the document (using the lang attribute) and helps in specifying metadata and other HTML structures within the document.