Text, links and images
Most of the web is text, links and pictures. Let's master all three.
Headings
HTML has six heading levels. <h1> is the main title (use one per page), and <h2>–<h6> create sections and subsections.
Choose headings by meaning, not size. Never skip from
<h2>to<h4>just because it looks smaller. Size is CSS's job. Screen-reader users and search engines navigate pages by their heading structure.
Paragraphs and text formatting
<strong> and <em> carry meaning. Use <b> and <i> only when you want the look without the importance.
Links
The <a> (anchor) element creates hyperlinks, the "HT" in HTML.
href type |
Example | Goes to |
|---|---|---|
| Absolute URL | https://site.com/page |
Any website |
| Relative path | about.html, ../img/logo.png |
A file relative to the current page |
| Root-relative | /blog/post-1 |
From the root of your site |
| Fragment | #contact |
An element with id="contact" on the page |
Write meaningful link text. "Read our pricing guide" is useful; "click here" isn't. Screen-reader users often jump from link to link and hear only the link text.
Images
src: where the image file is.alt: a text alternative. It's read by screen readers, shown if the image fails to load, and used by search engines. It's required. For purely decorative images, usealt="".width/height: reserve space so the page doesn't jump around while the image loads.
Try breaking the src URL to see the alt text appear.
Images with captions
Image formats
| Format | Best for |
|---|---|
| JPEG | Photos |
| PNG | Graphics with transparency, screenshots |
| SVG | Logos and icons (vector, so they stay sharp at any size) |
| WebP / AVIF | Modern formats: much smaller files for photos and graphics |
Practice
Create a mini "favourite place" article: an <h1>, an image with good alt text inside a <figure> with a caption, a paragraph with at least one <strong> word, and a link to learn more that opens in a new tab.
1.What is the alt attribute for?
2.How do you link to the element <section id="faq"> on the same page?