Every HTML page must follow a specific structure. This structure tells the browser what it's looking at and how to render it properly.
| Tag | Purpose | Required? |
|---|---|---|
| <!DOCTYPE html> | Declares this as an HTML5 document. Must be first. | Yes |
| <html> | Root element that wraps all content | Yes |
| <head> | Contains metadata and settings (not visible to users) | Yes |
| <title> | Page title shown in browser tab | Yes |
| <body> | Contains all visible page content | Yes |
The <head> section contains information about your page that isn't directly displayed:
<meta charset="UTF-8"> - Defines character encoding (UTF-8 is universal)
<meta name="viewport"...> - Makes page responsive for mobile devices
<title> - The page title (appears in browser tab and search results)
<link> - Links to external CSS files for styling
<style> - Internal CSS styles
<script> - JavaScript code or links to JS files
Everything inside the <body> tags is rendered and visible to users. This includes text, images, links, forms, and more.
Semantic tags describe the meaning of content, not just its appearance. They're better for accessibility and SEO.
| Tag | Meaning |
|---|---|
| <header> | Page or section header |
| <nav> | Navigation menu |
| <main> | Primary content area |
| <article> | Self-contained content (blog post, news item) |
| <section> | Thematic grouping of content |
| <aside> | Sidebar or supplementary content |
| <footer> | Page or section footer |
Always indent nested elements to make code readable:
Comments help explain your code and are ignored by browsers: