Links and images in HTML: href, src and alt
Why a link or image does not work, and why alt text matters.
All lessons · HTML lessons: learn from scratch
Links: href
The address of a link goes in href. A link to another site must start with https://; inside your own site you write a file path.
<a href="https://example.com" target="_blank" rel="noopener">External</a> <a href="about.html">About</a> <a href="#contact">Jump to contact</a> <a href="mailto:me@example.com">Email me</a>
Images: src and alt
<img src="images/cat.jpg" alt="A grey cat sleeping on a sofa" width="400">
- src — the image path. If it does not show, check the file name, folder and upper/lower case.
- alt — a text description for when the image fails and for screen readers. Do not skip it; use alt="" only for pure decoration.
- Set width/height so the page does not jump while loading.