Links and images

Join pages together and show pictures.

Your HTML is drawn by your own browser, inside this tab. Nothing to install.

Links

<a> makes a link. The text between its tags is what the reader clicks.

Where the link goes is written in an attribute. An attribute is extra information inside the opening tag, as a name, an equals sign and a value in quotes.

For a link the attribute is href.

Example
<p>Read the <a href="https://example.com/rules">library rules</a> before you join.</p>

Your turn: a link

Link to another site.

Practice task

Write a link whose text is Visit our catalogue and which goes to https://example.com/catalogue.

Your answer is run and checked in the lesson. Create a free account to try it.

Images

<img> shows a picture. It has no closing tag, because there is no text inside it.

src says where the picture file is. alt describes the picture in words.

The alt text is read aloud by screen readers and shown if the picture cannot load, so every image needs one.

Example
<img src="https://example.com/reading-room.jpg" alt="The reading room, with long wooden tables">

Your turn: an image

An image always needs a description.

Practice task

Add an image whose src is https://example.com/front-door.jpg and whose alt text is The library's front door.

Your answer is run and checked in the lesson. Create a free account to try it.

A picture that is a link

Anything between the tags of a link is clickable, and that includes an image.

Put the <img> inside the <a>. The image's alt text then also tells the reader where the link goes.

Example
<a href="https://example.com/map">
  <img src="https://example.com/map-small.jpg" alt="Map showing how to reach the library">
</a>