Lesson 5 of 14 · 6 min

Images

Pictures use the <img> tag:

<img src="https://bytepic.dev/assets/img/art/service-web-design.svg" alt="A web page layout being designed">

Three new ideas here:

  • <img> has no closing tag. There is nothing to put "inside" an image, so it stands alone. Tags like this are called empty or void elements.
  • src ("source") is the address of the picture, just like href on a link.
  • alt ("alternative text") describes the picture in words. Screen readers read it aloud to people who are blind or have low vision, and the browser shows it if the picture fails to load. Write what the picture shows, as you would describe it to a friend on the phone.

A page can hold as many images as you like, and an attribute's order inside the tag doesn't matter.

Your task

Under the heading, add an image:

  • src: https://bytepic.dev/assets/img/art/service-web-design.svg
  • alt: a short description of what you see, in your own words (at least two words).
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Images</title>
</head>
<body>
  <h1>My favourite picture</h1>
  <!-- Add your image here -->

</body>
</html>

Your page

Discussion

Stuck? Ask here. Be kind, and share hints rather than full answers.

Loading the discussion…