Links and attributes
Create links
Create clear hyperlinks with the anchor element, an href destination, and link text that makes sense outside its surrounding sentence.
6 minute lesson
Links are what make the Web a web.
Create one with the anchor element, a, and the href attribute:
<a href="https://example.com/guides/cycling/">Read the cycling guide</a>
The href value is the destination. The content between the tags is the link text.
Write text that describes where the link goes. “Read the cycling guide” is more useful than “click here,” especially when someone scans a list of links with assistive technology.
An anchor without href is not a hyperlink:
<a>Not a working link</a>
A link can contain an image or other phrasing content, but it cannot contain another link.
<a href="/">
<img src="logo.svg" alt="Acme home">
</a>
When an image is the only content of a link, its alt text should describe the link’s purpose.
Lesson completed