What HTML is
HTML stands for HyperText Markup Language. It is not a programming language: it does not make decisions or repeat steps. Instead, it marks up text so the browser knows which part is a heading, which part is a paragraph, which part is a link, and so on.
You mark up content with elements. Most elements have an opening tag, some content and a closing tag:
<p>This is a paragraph.</p>
The closing tag has a slash. Some elements, such as images, have no content and no closing tag.
The page skeleton
Every HTML page starts with the same few lines. Create a file named index.html and type this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first page</title>
</head>
<body>
</body>
</html>
<!doctype html>tells the browser to use modern HTML rules.lang="en"says the page is in English. Screen readers and search engines use it.- The
<head>holds information about the page.charset="utf-8"lets you use any letter or emoji, and the viewport line makes the page fit phone screens. - The
<title>is the text shown on the browser tab. - Everything visitors see goes inside
<body>.
Headings and paragraphs
Add content inside the body:
<body>
<h1>About me</h1>
<p>Hi! I am learning to build websites.</p>
<h2>My hobbies</h2>
<p>I like football, drawing and reading.</p>
</body>
Headings go from <h1> (most important) to <h6>. Use one <h1> for the page title, then <h2> for sections. Choose headings by meaning, not by size: you can change their size later with CSS.
Links, images and lists
A link uses the <a> element. The href attribute is where it goes:
<p>Read more on <a href="https://developer.mozilla.org/">MDN Web Docs</a>.</p>
An image uses <img>. Always add alt text that describes the picture for people who cannot see it:
<img src="cat.jpg" alt="A grey cat sleeping on a sofa" width="320">
Lists are either unordered (bullets) with <ul> or ordered (numbers) with <ol>. Each item is an <li>:
<ul>
<li>Football</li>
<li>Drawing</li>
<li>Reading</li>
</ul>Common mistakes
- Forgetting a closing tag. If everything after a point turns bold or becomes a link, look for a missing
</strong>or</a>. - Wrong nesting. Close tags in the reverse order you opened them:
<p><em>yes</em></p>, not<p><em>no</p></em>. - Broken image paths. The
srcis relative to the HTML file. If the image is in a folder namedimages, writeimages/cat.jpg. - Empty alt text on meaningful images. Only decorative images should use
alt="".
Try it yourself
Open Unays Code, paste the skeleton, and build an "About me" page with a heading, two paragraphs, a list of three hobbies and one link. Then continue with laying out the page with CSS.
This tutorial was written with AI assistance and reviewed by Unays. The runnable code examples were tested before publishing. Spotted a mistake? Tell us at [email protected].