On this page10 sections
Lecture 005: Headings & Paragraphs
| Category | 2: Text & Styles |
| Lecture | 005 of 048 |
| Estimated video length | 10 min |
| Target | HTML5 · any modern browser |
| Level | Beginner |
Most of the web is text. Headings give a page its outline, the way chapter titles do in a book, and paragraphs hold the reading itself. Get these two right and your pages are easy to read, for people and for search engines.
Learning Objectives
- Use the six heading levels
<h1>to<h6>in a sensible order - Write paragraphs with
<p>, and know when to use<br>and<hr> - Explain how the browser handles spaces and line breaks in text
1. Six Levels of Headings
<h1> is the most important heading and <h6> the least.
Example
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>2. Headings Are an Outline, Not a Font Size
Choose a heading level for its place in the outline, not for how big it looks. CSS can change the size later.
Example: a page outline:
<h1>Visiting Hunza</h1>
<h2>Getting there</h2>
<h3>By road</h3>
<h3>By air</h3>
<h2>Where to stay</h2>- Use one
<h1>per page: the page's main title. - Don't skip levels: go
<h2>→<h3>, not<h2>→<h5>.
Search engines and screen readers use this outline to understand the page.
3. Paragraphs
Each <p> is one block of text. The browser adds space above and below it automatically.
Example
<p>Hunza is a mountain valley in northern Pakistan.</p>
<p>It is famous for apricot blossoms in spring and golden trees in autumn.</p>4. The Browser Collapses White Space
Inside a paragraph, any run of spaces or line breaks becomes one space.
Example
<p>This text
has lots of
spaces and line breaks.</p>Run it: everything appears on one line with single spaces. To force a new line, use <br>.
To show text exactly as typed, use <pre>:
<pre>
Name: Sara
City: Karachi
</pre>5. Dividing Sections With <hr>
<hr> draws a horizontal line, which signals a change of topic.
Example
<p>That's all about spring.</p>
<hr>
<p>Now let's talk about autumn.</p>Common Beginner Mistakes
1. Picking headings by size. Using <h4> because "h2 is too big" breaks the outline.
Pick the correct level and resize with CSS.
2. Several <h1>s. Keep one main title per page.
3. Using <br><br> instead of paragraphs. Separate ideas belong in separate <p> elements.
4. Bold text instead of a heading. <p><strong>Getting there</strong></p> looks like a
heading, but search engines and screen readers won't treat it as one.
Practice Questions
- Which heading is the most important?
- How many
<h1>elements should a page usually have? - Your page has an
<h2>called "Prices". The next sub-section belongs under it. Which level should it use? - Why does
<p>Hello world</p>show only one space? - Which element keeps the spaces and line breaks exactly as written?
- Write a heading "Contact" followed by two short paragraphs.
Practice Answers
<h1>- One.
<h3>- The browser collapses any run of white space into a single space.
<pre>-
<h2>Contact</h2> <p>Call us on 0300-1234567.</p> <p>We reply within one day.</p>
Key Takeaways
- Headings
<h1>–<h6>form the page outline: one<h1>, no skipped levels. <p>holds one block of text; the browser spaces paragraphs for you.- Extra spaces collapse; use
<br>for a line break or<pre>for exact layout. <hr>marks a change of topic.