logo

HTML Document Structure

Understanding the basic structure of HTML documents

HTML Document Structure

Every HTML document follows a standard structure that browsers understand.

Basic HTML Template

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Page Title</title>
</head>
<body>
    <h1>Hello World!</h1>
    <p>This is a paragraph.</p>
</body>
</html>

Key Components

DOCTYPE Declaration

<!DOCTYPE html>

Tells the browser this is an HTML5 document.

HTML Element

<html lang="en">

The root element that contains all content.

Head Section

<head>
    <meta charset="UTF-8">
    <title>Page Title</title>
</head>

Contains metadata about the document.

Body Section

<body>
    <!-- All visible content goes here -->
</body>

Contains all the visible content of the page.

This structure is the foundation for every web page!