← All Exercises

Pair a Chart Image with figure and figcaption

basichtml~15min

Background

figure and figcaption associate media with its description, while intrinsic dimensions prevent layout shift during loading.

Problem

Publish a revenue chart with a concise alt text, a visible caption that explains the trend, and width and height attributes that reserve layout space before the image loads.

Input

A chart image source and a trend summary.

Output

A figure containing a sized image and a figcaption.

Sample tests

Sample 1

Input: Screen reader reaches the chart
Expected: img alt describes the chart data and figcaption is announced as the caption of the figure

Sample 2

Input: Page loads on a slow connection
Expected: width and height reserve the 16:9 box and loading=lazy defers the off-screen image

Your solution

Learning objective

Associate media with captions using figure and figcaption, and reserve space with intrinsic image dimensions.