MDN self-hosted library · e01.org

Test your skills: HTML images

Learnwebdevelopment/Core/Structuringcontent/HTMLvideoandaudio

no runnable cells learn-module-assessment upstream source

Learn_web_development/Core/Structuring_content/HTML_video_and_audio

The aim of this skill test is to help you assess whether you understand images and how to embed them in HTML.

[!NOTE] To get help, read our Test your skills usage guide. You can also reach out to us using one of our communication channels.

Images 1

In this task, we want you to embed an image of some Blueberries into the page.

To complete the task:

  1. Add the path to the image to an appropriate attribute to embed it on the page. The image is called blueberries.jpg, and it is available at a path of https://github.com/mdn/learning-area/blob/main/html/multimedia-and-embedding/tasks/images/blueberries.jpg?raw=true.
  2. Add some alternative text to an appropriate attribute to describe the image, for people that cannot see it.
  3. Give the <img> element a width attribute of 400 and an appropriate height attribute so that it displays at the correct aspect ratio, and doesn't cause a re-render when it loads. The image's intrinsic size is 615 x 419 pixels.

The starting point of the task looks like this:

100%

Here's the underlying code for this starting point:

```html live-sample___images-1

Basic image embed

You should see a picture of some blueberries above.


<!-- Shared/setup CSS code -->

```css hidden live-sample___images-1 live-sample___images-2 live-sample___images-3 live-sample___images-1-finished live-sample___images-2-finished live-sample___images-3-finished
body {
  background-color: white;
  color: #333333;
  font:
    1em / 1.4 "Helvetica Neue",
    "Helvetica",
    "Arial",
    sans-serif;
  padding: 1em;
  margin: 0;
}

* {
  box-sizing: border-box;
}

img {
  border: 1px solid black;
}

The updated content should look like this:

100%

Click here to show the solution Your finished HTML should look like this: ```html-nolint live-sample___images-1-finished

Basic image embed

blueberries

You should see a picture of some blueberries above.


We calculated the correct `height` value to set using the calculation 400 x 419/615.

</details>

## Images 2

In this task, you already have a full-featured image, but we'd like you to add a tooltip that appears when the image is moused over. You should put some appropriate information into the tooltip.

The starting point of the task looks like this:

100%

Here's the underlying code for this starting point:

```html live-sample___images-2
<h1>Basic image title</h1>

<img
  src="https://github.com/mdn/learning-area/blob/main/html/multimedia-and-embedding/tasks/images/larch.jpg?raw=true"
  alt="Several tall evergreen trees called larches" />
We've not provided finished content for this task, as it looks the same as the starting point.
Click here to show the solution Your finished HTML should look like this: ```html-nolint live-sample___images-2-finished

Basic image title

Several tall evergreen trees called larches

</details>

## Images 3

In this task, you are provided with both a full-featured image and some caption text. What you need to do here is add elements that will associate the image with the caption.

The starting point of the task looks like this:

100%

Here's the underlying code for this starting point:

```html live-sample___images-3
<h1>Image and caption</h1>

<img
  src="https://github.com/mdn/learning-area/blob/main/html/multimedia-and-embedding/tasks/images/firefox.png?raw=true"
  alt="An abstract flaming fox wrapping around a blue sphere"
  width="446"
  height="460" />
The 2019 Firefox logo
```css hidden live-sample___images-3 live-sample___images-3-finished figcaption { font-style: italic; }

The updated content should look like this:

100%

<details>
<summary>Click here to show the solution</summary>

Your finished HTML should look like this:

```html live-sample___images-3-finished
<h1>Image and caption</h1>

<figure>
  <img
    src="https://github.com/mdn/learning-area/blob/main/html/multimedia-and-embedding/tasks/images/firefox.png?raw=true"
    alt="An abstract flaming fox wrapping around a blue sphere"
    width="446"
    height="460" />
  <figcaption>The 2019 Firefox logo</figcaption>
</figure>
Learn_web_development/Core/Structuring_content/HTML_video_and_audio