The anchor Element and href Attribute
Create links with the anchor tag and href attribute.
What Is a Link?
The <a> (anchor) element creates a hyperlink — the fundamental building block of the web.
- Users click links to navigate between pages
- Links connect documents, resources, and locations
- Without links, the web would be a collection of isolated pages
The href Attribute
The href (hypertext reference) attribute specifies where the link goes:
<a href="https://example.com">Visit Example</a>
<a href="/about">About Us</a>
<a href="../contact.html">Contact</a>
<!-- href = destination URL or path
Content between tags = clickable text -->
<!-- Without href, a is still valid but not a hyperlink -->All lessons in this course
- The anchor Element and href Attribute
- Absolute vs Relative URLs
- Opening Links in New Tabs and Download Attribute
- Linking to Sections Fragment Identifiers