Skip to content
Guest
Learn HTML · Course Syllabus Show lessons
Media, Graphics & Data · 8 min read · Beginner

Links, Images & Media

Create accessible links, write meaningful alt text, prevent layout shift on images, and pair visuals with captions using figure.

What you'll learn

  • Write clear, accessible link text and safe external links
  • Use alt, width, height, and loading="lazy" on images for accessibility and performance
  • Group media with captions using <figure> and <figcaption>

Hyperlinks (<a>) and images (<img>) turn isolated documents into a connected, visual web. Getting their attributes right directly improves accessibility and Core Web Vitals (like Cumulative Layout Shift).

Screen-reader users often scan a page by listing all links out of context. That’s why link text should make sense on its own.

✓ Descriptive Link Text
<a href="/courses/css-layout">
Explore the CSS Layout course
</a>
✕ Vague Link Text
To start learning CSS,
<a href="/courses/css-layout">click here</a>.

When opening an external link in a new tab with target="_blank", always add rel="noopener noreferrer" for security.

Performant, Accessible Images

Every <img> should include:

  • alt: Describes the image’s purpose. Use an empty alt="" for purely decorative images so screen readers skip them.
  • width & height: Lets the browser reserve exact space before the image loads, preventing jarring page jumps (CLS).
  • loading="lazy": Defers off-screen images until the user scrolls near them. (Skip lazy loading on your main above-the-fold hero image!)

Try It Yourself

Edit the SVG data image, caption, or link attributes below:

Accessible Figure & Links
Live Result

Check Your Understanding

Score: 0 / 2

1. What alt attribute should you use on a purely decorative background icon?

2. Why should you include width and height attributes on <img> elements?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind