Home › HTML Tutorial › Links and images
Links and images
Connect pages with <a> and show pictures with <img>.
The href attribute sets where a link goes. Images need an alt text that describes them for people who can’t see them.
Commands in this lesson
href
Definition: Attribute of a that sets where the link goes.
Syntax:
<a href="URL">text</a>
Example:
<a href="https://example.com">Go</a>alt
Definition: Text description of an image, shown if it fails to load and read by screen readers.
Syntax:
<img src="file" alt="text">
Example:
<img src="x.png" alt="A sleeping cat">Example code
<a href="https://developer.mozilla.org" target="_blank">Visit MDN</a>
<br><br>
<img alt="A blue square" width="120" height="80"
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='80'%3E%3Crect width='120' height='80' fill='%232e86de'/%3E%3C/svg%3E">