⬅ Previous Next ➡

4. Basic Structure of HTML Document

Basic Structure of HTML Document
  • Basic Structure: Every HTML5 document follows a specific requirement of tags to be valid. These tags tell the browser how to interpret the file and organize the content.
  • The Essential Tags:
    • <!DOCTYPE html>: This is a declaration, not a tag. It tells the browser that the document is written in HTML5.
    • <html>: The root element. All other HTML elements must be nested inside this tag.
    • <head>: Contains metadata (information about the page). This data does not appear on the actual webpage, except for the title.
    • <title>: Sets the name of the page shown on the browser tab. It is also very important for SEO.
    • <body>: Contains all the visible content of the webpage, such as text, images, videos, and links.
  • The Tree Structure (Hierarchy):
    • HTML follows a parent-child relationship.
    • The <html> tag is the parent of <head> and <body>.
    • Elements inside the <body> are "children" of the body.
  • Key Rules:
    • Most tags come in pairs: an opening tag (e.g., <p>) and a closing tag (e.g., </p>).
    • Tags must be properly nested (the last tag opened must be the first one closed).
<!DOCTYPE html>
<html>
  <head>
    <title>Page Title Goes Here</title>
  </head>
  <body>
    <h1>Visible Heading</h1>
    <p>Visible paragraph content.</p>
  </body>
</html>
⬅ Previous Next ➡