You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Every HTML document follows a standard structure. Understanding this structure is essential before you can build anything on the web. Browsers rely on this structure to parse, render, and display your content correctly.
The very first line of every HTML file should be the DOCTYPE declaration:
<!DOCTYPE html>
This tells the browser that the document uses HTML5, the modern standard. Without it, browsers may fall back to a compatibility mode called quirks mode that renders pages inconsistently.
The entire document is wrapped in the html element. The lang attribute tells assistive technologies (like screen readers) and search engines what language the page is written in:
<html lang="en">
...
</html>
The head element contains metadata — information about the page that is not displayed directly to the user:
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="A short description of the page." />
<title>Page Title</title>
<link rel="stylesheet" href="styles.css" />
</head>
Key elements inside head:
The body element contains everything that is visible to the user:
<body>
<header>
<h1>My Website</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<h2>Welcome</h2>
<p>Thanks for visiting!</p>
</main>
<footer>
<p>© 2025 My Website</p>
</footer>
</body>
HTML elements can be nested inside one another, creating a tree structure called the DOM (Document Object Model). Proper indentation is not required by the browser but is essential for human readability. The convention is two or four spaces per nesting level.
Putting it all together, here is the standard boilerplate every HTML project starts with:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.