Chapter 5
Beginner
8 min read
Core Elements
Links & Anchors
Hyperlinks are what make the web a web. The anchor tag creates links to other pages, external websites, email addresses, and sections within the same page.
🎯 What you'll learn
✓Create links to other pages and
websites
✓Open links in a new tab
✓Link to email addresses and
phone numbers
✓Create anchor links within a
page
Basic Links
The <a> (anchor) tag creates
hyperlinks. The
href attribute specifies the destination URL.
HTML
<!-- External link -->
<a href="https://k2infocom.com">Visit K2infocom</a>
<!-- Open in new tab -->
<a href="https://k2infocom.com" target="_blank" rel="noopener">New Tab</a>
<!-- Internal link -->
<a href="about.html">About Us</a>
Link Types
href="https://..."
Absolute URL — links to any external website.
href="page.html"
Relative URL — links to another file in the same folder.
href="#section-id"
Anchor link — jumps to an element with that ID on the same
page.
href="mailto:a@b.com"
Opens the user's email client with the address pre-filled.
href="tel:+919876543210"
On mobile, tapping this dials the phone number directly.
🔒 Security Tip
Always add rel="noopener noreferrer" when using target="_blank".
Try It Yourself
Live Editor
✎ Editor
👁 Preview
❓ Quick Check — Chapter 5
Which attribute on <a> makes a link open in a new browser tab?
📄 Chapter Summary
- The
<a href="...">tag creates hyperlinks. - Use
target="_blank"to open links in a new tab. - Add
rel="noopener noreferrer"for security. - Use
href="#id"for same-page anchor navigation.