HTML Basics: Build Your First Web Page
Headings, Paragraphs and Text
In this lesson you will
- Use the six heading levels in the right order
- Write paragraphs and line breaks
- Emphasise text with strong and em
Introduction
Open any article and you will see a big title, smaller section titles, and paragraphs of text. In HTML, each of those has its own tag. Using the right tag helps readers, search engines and screen readers understand your page.
Headings
HTML has six heading levels, from h1 (the most important) to h6 (the least).
Think of a book. h1 is the book title, h2 is a chapter, h3 is a part of a chapter.
Two good habits:
- Use one
h1on a page, for its main title. - Do not skip levels. Go from
h2toh3, not fromh2toh5.
Quick quiz
Which heading tag is the most important?
Paragraphs
The p element is for a paragraph of text. The browser adds space above and below each one.
A surprise for beginners: the browser ignores extra spaces and blank lines in your code. Many spaces in a row show as one space. If you want a new paragraph, use a new p element.
Line breaks and lines
<br>forces a line break inside text, like in an address or a poem.<hr>draws a horizontal line to separate topics.
These two have no closing tag, because they have no content. They are called void elements.
Strong and emphasis
Use strong for important text and em for emphasis. Browsers show them as bold and italic, but they also tell screen readers how to speak the words.
Try it yourself
Build a small "About me" page. Add an h1 with your name, an h2 called "Hobbies", and a paragraph that uses strong for one word. Press Run to check it.
Quick quiz
Which tag has no closing tag?
Summary
- Use
h1toh6for headings, with oneh1per page. - Use
pfor paragraphs. Extra spaces in code are ignored. brandhrhave no closing tag.- Use
strongfor importance andemfor emphasis.
Lesson complete
+20 XP
Nice work. Keep going while it is fresh.
Sources and further reading