Web Development · Module 2 · Lesson 21 min read

Text, Links & Images

Headings and text

  • <h1> to <h6>: headings. Use one <h1> per page and don't skip levels; screen readers and Google use them to understand the page.
  • <p> paragraph, <br> line break, <hr> divider.
  • <strong> important (bold), <em> emphasis (italic), <code> code, <blockquote> quotes.
HTML
<a href="https://example.com">External site</a>
<a href="/about">Page on my site</a>
<a href="#contact">Jump to a section</a>
<a href="mailto:hi@example.com">Email me</a>
<a href="https://example.com" target="_blank" rel="noopener">Opens in new tab</a>

Write link text that makes sense on its own: "Read the pricing guide", not "click here".

Images

HTML
<img src="cat.jpg" alt="A ginger cat sleeping on a sofa" width="600" height="400">
  • alt text is required: it's read by screen readers and shown if the image fails. Use alt="" for purely decorative images.
  • Setting width and height prevents the page jumping while images load.
  • Use modern formats (WebP, AVIF) and loading="lazy" for images further down the page.

Figures

<figure> with <figcaption> groups an image with its caption.

Example

HTML
<h1>My Travel Blog</h1>
<p>Last summer I visited <strong>Pokhara</strong>, and it was <em>amazing</em>.</p>

<figure>
  <img
    src="https://picsum.photos/600/300"
    alt="Mountain lake at sunrise"
    width="600" height="300"
    loading="lazy" />
  <figcaption>Phewa Lake in the morning</figcaption>
</figure>

<p>
  Read more on <a href="https://en.wikipedia.org/wiki/Pokhara" target="_blank" rel="noopener">Wikipedia</a>
  or <a href="#contact">contact me</a>.
</p>
<h2 id="contact">Contact</h2>
<a href="mailto:hello@example.com">hello@example.com</a>