Tag html

The html tag is the root element of an HTML document. It wraps all the content on the page, including the head and body sections. All other HTML elements should be nested inside the html tag.


✅ Basic Syntax

<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is a paragraph.</p>
</body>
</html>

🔑 Key Points

  • Root Element: The <html> element is the highest-level element in the document, containing all other HTML elements.
  • Attributes: The most common attribute for <html> is the lang attribute, which specifies the language of the document.

Example with lang Attribute:

<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
  • lang="en" specifies that the page is in English. This is important for accessibility, as it helps screen readers or search engines know which language the page is written in.

🎯 Why Is <html> Important?

  • Document Structure: The <html> tag is the foundational structure for all HTML documents.
  • Semantic Meaning: It provides a clear boundary for all the content in the document and helps browsers properly render the content.
  • Accessibility and SEO: The lang attribute aids search engines in indexing the content correctly and ensures better accessibility for screen readers.

⚠️ Notes

  • The <html> tag should always be the first element in your document.
  • It must contain both the <head> and <body> tags.

✅ Summary

Feature<html> Tag
PurposeRoot element of an HTML document
UsageWraps all other elements in the document
Common Attributelang (specifies language of the page)
DisplayNot directly visible on the webpage