Understanding the Structure of an HTML Document

Every HTML document starts with <!DOCTYPE html>, which tells the browser to render in standards mode. The root <html> element wraps the entire page. Inside, the <head> contains metadata such as the page title and character set, while the <body> holds all visible content.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

Key Points

  • Doctype Declaration: <!DOCTYPE html> triggers standards mode.
  • Root Element: <html lang="en"> wraps all content and specifies language.
  • Head Section: Metadata like <meta charset="UTF-8"> and page title.
  • Body Section: Visible elements such as headings and paragraphs.