Skip to the content

Lesson 8 of 296

Text, headings, links and images

What you will learn

  • Headings and the right order to use them
  • Paragraphs and text elements
  • Links: to other sites, to other pages, inside a page, email and phone
  • Images: the attributes that matter and why
  • Basic audio and video
On this page

Headings

There are six heading levels, from <h1> (most important) to <h6> (least important).

<h1>Learn to Cook</h1>
  <h2>Breakfast</h2>
    <h3>Eggs</h3>
    <h3>Pancakes</h3>
  <h2>Dinner</h2>

Rules:

  • Use one <h1> per page for the main title. It is the clearest structure for users and search engines.
  • Do not skip levels. After <h2> comes <h3>, not <h5>.
  • Choose the level by meaning, not by size. If you want a smaller heading, change the size with CSS.

Screen reader users often jump from heading to heading to scan a page, the same way you scan a page with your eyes. A correct heading order makes this work.

Paragraphs and text elements

<p>This is a paragraph.</p>
<p>This is another paragraph.<br>This line starts after a line break.</p>
ElementMeaningDefault look
<p>A paragraphBlock with space around it
<strong>Strong importanceBold
<em>Emphasis (stress when spoken)Italic
<b>Bold with no extra meaningBold
<i>Italic with no extra meaning, for example a foreign wordItalic
<mark>Highlighted textYellow background
<small>Small print, such as legal notesSmaller
<code>A piece of codeMonospace font
<pre>Text where spaces and line breaks are keptMonospace font
<blockquote>A long quote from another sourceIndented
<br>A line break inside the same paragraph-

<strong> or <b>? Both look bold. <strong> tells screen readers and search engines the text is important. <b> only changes the look. Use <strong> when the text really is important.

A link is made with the <a> element (a for "anchor"). The href attribute says where it goes.

To another website: use the full URL.

<a href="https://www.gov.uk">GOV.UK</a>

To another page on your site: use a path.

<a href="/about">About us</a>
<a href="contact.html">Contact</a>

To a part of the same page: use # and the id of the element.

<a href="#prices">See prices</a>
...
<h2 id="prices">Prices</h2>

To open an email app or dial a phone number:

<a href="mailto:hello@example.com">hello@example.com</a>
<a href="tel:+441134960000">0113 496 0000</a>

To open in a new tab:

<a href="https://example.com" target="_blank" rel="noopener noreferrer">Example</a>

target="_blank" opens a new tab. rel="noopener" stops the new page from controlling your page through JavaScript. Modern browsers now add this protection by default, but many teams still write it so the protection is clear in the code.

Link text matters. Write text that says where the link goes.

Bad:   To see our prices, <a href="/prices">click here</a>.
Good:  See our <a href="/prices">price list</a>.

Screen reader users can list all links on a page. A list of ten "click here" links is useless.

  • A link (<a>) takes the user to another place (a URL).
  • A button (<button>) does an action on the current page: submit a form, open a menu, delete an item.

Using the wrong one breaks keyboard use and screen readers. This is a common interview question.

Images

<img src="/images/team.jpg" alt="Our five team members in the office" width="800" height="500">
AttributeWhy it matters
srcThe path to the image file. Required.
altA text description. Read aloud by screen readers. Shown if the image fails to load. Used by search engines.
width and heightThe real size in pixels. The browser reserves the space before the image loads, so the page does not jump.
loading="lazy"Only loads the image when the user scrolls near it. Makes pages faster.

How to write good alt text

  • Describe what the image shows and why it is there, in a short sentence.
  • Do not start with "Image of" or "Picture of". Screen readers already say it is an image.
  • If the image is only decoration, use an empty alt: alt="". The screen reader then skips it. Do not leave the alt attribute out completely.
  • If the image is a link or a button, describe the action: alt="Go to home page".

Image formats

FormatBest for
.jpgPhotos
.pngImages that need a see-through background, screenshots
.webp / .avifModern formats with smaller files. Good default for photos today.
.svgLogos and icons. Made of shapes, so they stay sharp at any size.

Images with captions

<figure>
  <img src="chart.png" alt="Sales rose from 200 to 450 between 2023 and 2025">
  <figcaption>Figure 1: Yearly sales</figcaption>
</figure>

Audio and video

<video src="intro.mp4" controls width="640"></video>
<audio src="podcast.mp3" controls></audio>

controls shows the play and pause buttons.

Common mistakes

  • Missing alt text. It is the most common accessibility failure on the web.
  • Choosing a heading level for its size. Use CSS for size.
  • "Click here" links.
  • Huge image files. A 5 MB photo makes the page slow on phones. Resize and compress images before using them.
  • Using a link with href="#" as a button. Use <button> for actions.

How to say it in an interview

"I use one h1 per page and keep heading levels in order, because screen reader users navigate by headings. Links go to a new URL and buttons do actions. Every image gets alt text that describes its purpose, or an empty alt if it is decoration, and I set width and height so the layout does not shift while images load."

Key words

WordMeaning
HeadingA title element, <h1> to <h6>
AnchorThe <a> element, used for links
hrefThe attribute that holds a link's destination
Alt textA text description of an image
Lazy loadingLoading an image only when it is needed
Layout shiftThe page jumping when content loads late

Now prove it

This lesson is complete when you pass the quiz and all three practice levels.