Lesson 3 of 23
In progress
Headings, paragraphs and text emphasis
Build a readable document outline with h1 to h6, write paragraphs people can scan, and use emphasis that carries meaning.
Headings are not font sizes. They are the outline of your document, and that outline is what a screen reader user navigates by, what a search engine reads, and what a reader skims before deciding to stay.
What you will learn
- Use
h1toh6in a logical order. - Write paragraphs that survive narrow screens and long reading sessions.
- Use
strongandemfor meaning rather than appearance.
One topic, one h1
The h1 states the page’s subject. Every other heading sits beneath it in a sensible hierarchy: h2 for major sections, h3 for subsections of those.
Editable. Runs in your browser.
<h2>Flexbox</h2>
<p>One-dimensional layout for rows and columns.</p>
<h2>Grid</h2>
<p>Two-dimensional layout for rows and columns together.</p>
<h3>When to use Grid</h3>
<p>When alignment across rows and columns matters.</p>
Press Run to see the output.
The h3 belongs to Grid because it is nested inside that section. Do not skip from h2 to h4 because the size looks better; that tells assistive technology a level is missing. Size is CSS’s job.
If a page genuinely has two unrelated main topics, it probably wants two pages. A single h1 keeps the outline honest.
Paragraphs are the unit of reading
A p holds a thought, not a line. Browsers wrap it to the viewport, so never press Enter to force a line break in the middle of a sentence.
Editable. Runs in your browser.
<p>Two paragraphs are separated by space, which is why the closing
and opening tags matter more than the line breaks in the source.</p>
Press Run to see the output.
Each p gets vertical space from the browser’s default styles. If you need a new line inside a paragraph — an address, a poem, a short line of code — use br. Using br between paragraphs is a sign you wanted two paragraphs.
Long paragraphs are hard to read on any screen. Three to five sentences is a comfortable length on the web, and a blank line between ideas costs nothing.
Emphasis that means something
strong marks importance, em marks stress. Browsers render them bold and italic by default, but the tags carry meaning that b and i do not.
Editable. Runs in your browser.
Press Run to see the output.
Use strong sparingly. A page where everything is important has no emphasis left. If you only want bold text for visual reasons and there is no importance, that is a CSS decision.
Code, file names and keyboard keys have their own elements: code, kbd, samp. They also default to a monospace font, but their meaning is more specific than a generic span.
Blocks stack, inline flows
Headings and paragraphs are block elements: each starts on a new line and takes the available width. strong, em, a and code are inline: they sit inside a line of text.
Editable. Runs in your browser.
Press Run to see the output.
Putting a block element inside a paragraph is invalid. A div or h2 inside p causes the browser to close the paragraph early, which produces a DOM you did not write. The Elements panel shows this immediately, and it is worth checking when a layout behaves strangely.
Readable text is a design decision
Line length matters. A paragraph stretching across a wide monitor is tiring; something around 60 to 75 characters per line is comfortable. CSS handles that with a maximum width, not with manual line breaks.
Also avoid writing in all capitals for whole paragraphs. It slows reading, and screen readers may spell out abbreviations. If you want capitals for a visual style, use text-transform in CSS later.
Using an empty heading or a heading purely for spacing, such as <h2> </h2>, creates a phantom section in the outline. Screen reader users hear "heading level 2" with nothing after it. Use margin for space and headings for names.
Write a short page about a hobby. Give it one h1, two h2 sections, and one h3 under the second section. Include a paragraph, one strong, one em, and one paragraph with a br where a line break is genuinely part of the content.
Show solution
Editable. Runs in your browser.
<h2>What you need</h2>
<p>A bowl, a scale and <em>patience</em>.</p>
<h2>The first loaf</h2>
<p>Mix, wait, shape, wait, bake.</p>
<h3>Timing</h3>
<p>Start in the morning.<br>Bake before dinner.</p>
Press Run to see the output.
The br separates two lines that are meant to be read as separate lines. Everything else is a real paragraph, and the headings nest without skipping a level.
Recap
- One
h1per page, withh2andh3nested in order; headings describe sections. - A
pis a thought that wraps naturally;bris only for genuine line breaks. strongandemcarry meaning, and block elements never go inside a paragraph.
Next, you will connect pages with links, including the difference between relative and absolute paths.
Can I use h1 more than once?
Should I use b and i instead of strong and em?
Progress is saved in this browser only. No account, no email.