About HTML
HTML (HyperText Markup Language) describes the structure and meaning of web content. It gives browsers the headings, links, images and forms that make up a page.
- Web pages
- Forms
- Accessible content
- Created by
- Tim Berners-Lee at CERN
- First released
- 1991 · first public description
- Version / standard
- HTML Living Standard
Continuously updated; there is no single latest numbered release.
In the real world
- GOV.UK: Government service pages and forms
- PayPal: Checkout page markup
- GitHub: Primer web interface components
Facts checked 8 September 2026. Links open the sources; examples describe specific products or documented uses.
Syntax
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>Examples
Your first document
A complete page you can save as index.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My learning journal</title>
</head>
<body>
<h1>Today I learned HTML</h1>
<p>Every page starts with structure.</p>
</body>
</html>Meaningful sections
Give a page useful landmarks.
<header><h1>Learning journal</h1></header>
<main>
<section aria-labelledby="today">
<h2 id="today">Today</h2>
<p>I built my first page.</p>
</section>
</main>
<footer>Written by a curious developer</footer>A small resource page
Combine metadata, navigation and readable content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTML resources</title>
</head>
<body>
<a href="#resources">Skip to resources</a>
<header><h1>Developer reading list</h1></header>
<main id="resources">
<h2>Start here</h2>
<ul><li><a href="https://html.spec.whatwg.org/">HTML Standard</a></li></ul>
</main>
</body>
</html>Basic Page Structure
A minimal HTML document with proper structure including DOCTYPE, head, and body sections.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Page</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a paragraph.</p>
</body>
</html>Semantic Structure
Using HTML5 semantic elements like header, nav, main, and footer for better document structure and accessibility.
<header>
<h1>Website Title</h1>
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
</nav>
</header>
<main>
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
</main>
<footer>
<p>© 2024 Company</p>
</footer>Complete Website Template
A comprehensive HTML template with meta tags, semantic structure, and common elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Website description">
<title>Professional Website</title>
</head>
<body>
<header>
<h1>Site Name</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section id="home">
<h2>Welcome</h2>
<p>Main content here</p>
</section>
</main>
<footer>
<p>Contact: info@example.com</p>
</footer>
</body>
</html>Best practices
- Always include a DOCTYPE declaration at the beginning of your HTML documents
- Use semantic HTML5 elements (header, nav, main, article, footer) for better structure and accessibility
- Include proper meta tags for character encoding and viewport settings
- Ensure all images have descriptive alt text for accessibility
- Validate your HTML using the W3C Markup Validation Service
- Keep your HTML structure clean and properly indented for maintainability
At a glance
- Purpose
- Structure and meaning for web content
- File extension
- .html · .htm
- Runs in
- Web browsers
- Usually used with
- CSS and JavaScript
In plain English
HTML gives a page its structure and meaning. The browser turns your markup into a tree of elements; CSS styles that tree and JavaScript can change it.
What you’ll learn
- Build a complete document.
- Separate page metadata from visible content.
- Choose meaningful elements and set the page language.
Breaking down the syntax
<!DOCTYPE html>- Requests standards mode; it is a declaration, not an element.
<html lang="en">- The document root. lang identifies the human language.
<head>- Holds metadata such as the title and character encoding.
<body>- Contains the page content users interact with.
How it works
HTML source
You write elements, attributes and text.
Document tree
The browser parses the source into a DOM tree rooted at html, with head and body children.
Page on screen
The browser combines the tree with styles to lay out and paint the page.
When should I use this?
Start here when creating a web page or understanding the markup produced by a framework. Use CSS for appearance and JavaScript for behaviour.
Common mistakes
Visible content inside the head
The head is for metadata. Browser error recovery can move misplaced content, so the resulting DOM may differ from the source.
Incorrect
<head>
<h1>Hello</h1>
</head>Corrected
<head><title>Welcome</title></head>
<body><h1>Hello</h1></body>Compare approaches
- <div>: A generic container when no semantic element fits.
- <section>: A thematic section, normally identified by a heading.
Accessibility
- Set lang to the actual language of the content.
- Use a clear heading hierarchy and landmarks such as main and nav.
- Use meaningful alt text for informative images; decorative images usually need alt="".
Explore deeper
Source markup and the DOM can differ
The HTML parser has defined error-recovery rules and can insert missing elements. Inspect the DOM as well as the page source when debugging. Some HTML end tags may be omitted under specific rules; explicit tags are often easier for beginners to read.
Specifications & further reading
Related HTML documentation
The <div> element is a generic container used to group and organize content on a web page. It has no semantic meaning on its own but is essential for layout and styling. Think of it as a box that can hold other HTML elements. Divs are block-level elements, meaning they start on a new line and take up the full width available.<body>
The <body> element contains all the visible content of an HTML document — text, images, links, forms, and everything a user actually sees and interacts with in the browser. There can only be one <body> per document, and it must come after the <head> element. Unlike <head>, which holds metadata, everything inside <body> is rendered on the page.<head>
The <head> element contains metadata about the document — information that is not displayed directly on the page but is used by browsers, search engines, and other tools. This includes the page <title>, character encoding, linked stylesheets, scripts, and social media preview data. It must come before <body> and contains no visible content itself.<hgroup>
The <hgroup> element groups a heading with one or more subheadings or taglines, treating them as a single unit in the document outline. It is commonly used to pair a main title with a subtitle, so the subtitle does not get counted as its own separate heading level by accessibility tools.