Stop 03 · HTML FundamentalsTopics · 3/10

Links and Images

Part of the Web Development Roadmap

In short

Links are what make the web a web, and images make pages feel alive. Two small tags, a and img, but getting their attributes right matters for users, screen readers and search.

The anchor tag links pages together using href, and the img tag shows pictures using src and alt text that describes the image for screen readers and when it fails to load.

The jaadu stands on a railway platform pointing up at a big arrow-shaped signboard, while a framed photo hangs on the wall beside it.

Think of it like this

Signboards and framed photos

In a railway station, signboards point you to other platforms; that's a link, with href as the destination. On the waiting room wall hangs a framed photo with a small card underneath describing it for anyone who can't see it clearly. That's an image, with src as the photo and alt as the description card.

The big ideas

What you need to know

href is the destination

Absolute links include the full address (https://...). Relative links like about.html or images/logo.png point to files in your own project.

Opening a new tab

target="_blank" opens a new tab. Use it for external sites, and add rel="noopener" for safety.

src and alt

src is the image path. alt describes the picture for screen readers and shows if the image fails to load.

Jump within a page

Give an element an id, like id="contact", and link to it with href="#contact".

See it in code

Walk through the code

html
1<nav>2  <a href="index.html">Home</a>3  <a href="about.html">About</a>4  <a href="#contact">Contact</a>5</nav>6 7<img8  src="images/chai-stall.jpg"9  alt="A roadside chai stall with glasses of tea on a wooden counter"10  width="600"11  height="400"12/>13 14<p>15  Find us on16  <a href="https://maps.google.com" target="_blank" rel="noopener">Google Maps</a>.17</p>18 19<section id="contact">20  <h2>Contact</h2>21  <a href="mailto:hello@example.com">Email us</a>22</section>

1/5Relative links to other pages in the same folder.

Relative, absolute, same-page and email links, plus an image with good alt text.

Save yourself the pain

Common mistakes

Oops

Writing alt="image" or leaving alt out.

Do this instead

Describe what the image shows. For purely decorative images use an empty alt="" so screen readers skip them.

Oops

Linking to C:/Users/Rahul/Desktop/photo.jpg.

Do this instead

Use relative paths like images/photo.jpg. Full computer paths break as soon as the site is hosted.

Your mission

Link up a mini site

~20 min

Quick check

Your about.html is in the same folder as index.html. Which link is correct from index.html?

Go deeper

  1. 1Practise absolute links, relative links and links that jump to a section on the same page.
  2. 2Write meaningful alt text for five images, and use an empty alt for purely decorative ones.
  3. 3Add width and height to images so the page doesn't jump while they load.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge