HTML Basics
HTML Links
Links are what make the web a web. The anchor element, <a>, turns text or images into clickable links to other pages, sections, emails, or files.
The Anchor Tag
A link is created with the <a> element and its href attribute, which holds the destination address.
<a href="https://example.com">Visit Example</a>Absolute vs Relative Links
- Absolute URL: the full web address, e.g. href="https://example.com/page".
- Relative URL: a path relative to the current page, e.g. href="about.html".
Useful Link Variations
<!-- Open in a new tab -->
<a href="https://example.com" target="_blank" rel="noopener">New tab</a>
<!-- Email link -->
<a href="mailto:hello@example.com">Email us</a>
<!-- Phone link -->
<a href="tel:+911234567890">Call us</a>
<!-- Jump to a section on the same page -->
<a href="#contact">Go to contact</a>
<h2 id="contact">Contact</h2>⚠️
When you use target="_blank", add rel="noopener" for security. It stops the new page from being able to control the tab that opened it.
