Book 3 — HTML, CSS Basics

Python for All

Chapter Three — Links & Images

Thanasis Troboukis  ·  All Books

Book Three · Chapter Three

Links & Images

Hyperlinks are the foundation of the web. Images bring stories to life. This chapter shows you how to add both — and how to do it properly.

Hyperlinks — Connecting the Web

The hyperlink is the defining feature of the web. It is what turns a collection of documents into a network. In journalism, links serve two purposes: they credit your sources, and they give readers a path to verify what you have written.

A link is created with the <a> tag (anchor). It has one essential attribute: href (HyperText REFerence), which holds the destination URL. The text between the opening and closing tag is what the reader clicks.

HTML · Try it

HTML

CSS

Live Preview

Opening links in a new tab

When you link to an external source, it is good practice to open it in a new browser tab, so the reader does not leave your article. Add two attributes to the <a> tag: target="_blank" to open a new tab, and rel="noopener noreferrer" as a security measure.

HTML · Try it

HTML

CSS

Live Preview

Link text matters: Never write "click here". Screen readers and search engines read link text to understand what the destination is about. Write descriptive text: "read the full WHO report", "view the city's housing plan".

Images — Adding Photographs

Images are added with the <img> tag. Unlike most tags, it is self-closing — it has no content between tags and no closing tag. It has two required attributes:

HTML · Try it

HTML

CSS

Live Preview

The CSS rule max-width: 100% ensures the image never overflows its container, no matter how large the original file is. height: auto preserves the aspect ratio. These two lines should appear in every article you publish.

Captions — figure and figcaption

A bare <img> tag has no caption. In journalism, every photo needs one: who is in the frame, where it was taken, when, and by whom. HTML provides a semantic wrapper for exactly this: <figure> and <figcaption>.

Wrap the image in <figure>, then add a <figcaption> directly after the <img>.

HTML · Try it

HTML

CSS

Live Preview

Your Turn — A Story With Sources and a Photo

Build a short article that includes:

You can use any image from Wikimedia Commons by right-clicking it and copying the image URL, or use the example URL below.

HTML · Your turn

HTML

CSS

Live Preview

What you have learned in this chapter: <a href> for hyperlinks, target="_blank" rel="noopener noreferrer" for safe external links, <img src alt> for images, and <figure>/<figcaption> for captioned photos. Next: the semantic structure of a full article page.

Chapter Navigation

Move between chapters.