3. HTML Document Structure

Every HTML page follows a standard structure. This is the skeleton of every website you build.

Basic Structure:
<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
    Content goes here
  </body>
</html>

1. <!DOCTYPE html>

Definition: Declares that the document is written in HTML5.

Rule: Must be placed at the top of the document.

<!DOCTYPE html>

2. <html>

Definition: The root element of the HTML document.

Rule: All HTML code must be written inside the <html> tag.

Example:
<html> 
  <!-- All tags go here -->
</html>

3. <head>

Definition: Contains metadata (information about the webpage).

Examples of content:
  • Title
  • CSS links
  • Meta tags
<head>
  <title>My Website</title>
</head>

4. <body>

Definition: Contains the visible content of the webpage.

Examples:
  • Text, Images, Links
  • Forms, Videos
<body>
  <h1>Hello World</h1>
  <p>This is my webpage.</p>
</body>