๐ Short Intro (Why Iโm Writing This)
Iโm currently learning HTML and decided to learn in public by documenting my journey.
This blog is part of my HTML-101 series, where Iโm learning HTML step by step from scratch.
This series is not written by an expert โ itโs a beginner learning out loud, sharing:
- what I understand,
- what confuses me,
- and what I learn along the way.
The goal is to build consistency, clarity, and invite discussion.
๐ What This Blog Covers
In this post, Iโll cover:
- Quick recap โ what paths are (short)
- Anchor tag basics (
<a>) and anatomy - Types of href values (absolute, relative, fragment, mailto, tel)
- Important attributes:
target,rel,download,title - Link states, styling, accessibility & keyboard behavior
- Mailto links: formats and extra parameters (subject, body)
- Tel links: formatting and best practices
- When to use links vs buttons
- Common mistakes and tips
๐ GitHub Repository
All my notes, examples, and practice code live here:
๐ GitHub Repo:
https://github.com/dmz-v-x/html-101
This repo is updated as I continue learning.
๐ Learning Notes
1. Quick recap โ What a path is (1 line)
A path tells the browser where to find a file (image, page, script, stylesheet).
Examples:
<img src="images/logo.png">
<a href="pages/about.html">About</a>
<link rel="stylesheet" href="css/style.css">
- Difference between
src,hrefandrel
| Attribute | What it means | Loads file? | Used for |
|---|---|---|---|
src |
Source of content | โ Yes | Images, JS, media |
href |
Link/reference | โ ๏ธ Sometimes | Pages, CSS |
rel |
Relationship | โ No | Explains purpose |
2. Anchor tag basics โ what is <a>?
<a> (anchor) creates clickable links.
Basic example:
<a href="https://example.com">Visit Example</a>
-
href= destination (required for a real link) - Link text = what users see and click
If href is missing, <a> is not treated as a link by browsers and assistive tech.
3. Types of href values
3.1 Absolute URL (external)
Full web address with protocol:
<a href="https://youtube.com">YouTube</a>
Use when linking to another website or CDN.
3.2 Root-relative path
Starts from the site root (/):
<a href="/about">About</a>
<img src="/assets/images/logo.png">
Works reliably when the site is hosted at domain root.
3.3 Relative path
Relative to the current fileโs folder:
<!-- current file: /project/index.html -->
<a href="pages/about.html">About</a>
<img src="images/logo.png">
Use for files inside the same project.
3.4 Fragment / Anchor (jump within page)
Jump to an element with a matching id:
<h2 id="projects">Projects</h2>
<a href="#projects">Go to Projects</a>
3.5 mailto: (email) and tel: (phone)
Special schemes that launch apps:
<a href="mailto:someone@example.com">Email me</a>
<a href="tel:+911234567890">Call me</a>
4. Anchor tag anatomy (basic + attributes)
<a href="URL" target="_blank" rel="noopener noreferrer" title="Tooltip">
Link Text
</a>
-
hrefโ destination (URL, path, mailto, tel, or fragment) -
targetโ where to open (_self,_blank,_parent,_top) -
relโ relationship / security (important with_blank)-
noopenerprevents the new page from gettingwindow.opener -
noreferrerprevents sending the referrer URL
-
-
downloadโ suggests downloading the resource instead of navigating -
titleโ tooltip (use sparingly; not always helpful for accessibility)
| Attribute | Value(s) | What it does (plain English) | When it comes into play | When to use it | Example |
|---|---|---|---|---|---|
target |
_self |
Opens link in same tab | When link is clicked | Default behavior | <a href="page.html" target="_self"> |
target |
_blank |
Opens link in new tab | When link is clicked | External sites | <a href="https://google.com" target="_blank"> |
target |
_parent |
Opens link in parent frame | Inside iframe | When using iframes | <a href="x.html" target="_parent"> |
target |
_top |
Opens link in full window | Inside nested iframes | Break out of frames | <a href="x.html" target="_top"> |
rel |
noopener |
Blocks access to window.opener
|
With target="_blank"
|
Security | <a target="_blank" rel="noopener"> |
rel |
noreferrer |
Hides referrer info | With external links | Privacy | <a rel="noreferrer"> |
download |
filename (optional) | Forces file download | On click | Download files | <a download> |
title |
text | Shows tooltip on hover | On mouse hover | Extra hint text | <a title="Info"> |
Safe new-tab pattern (always do this):
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
External site
</a>
5. Link states & basic styling
Browsers provide pseudo-classes for link states:
-
a:linkโ unvisited link -
a:visitedโ visited link -
a:hoverโ mouse over -
a:activeโ pressed/clicking -
a:focusโ focused via keyboard (Tab)
Order in CSS: :link, :visited, :hover, :active, :focus (LVHAF).
Basic styling example:
a {
color: #1e90ff;
text-decoration: none; /* remove underline */
}
a:hover {
text-decoration: underline;
}
a:focus {
outline: 3px solid #f59e0b;
outline-offset: 2px;
}
Usability tip: If you remove underline, show a clear hover or focus indicator so users know itโs a link.
6. Accessibility & keyboard behavior
- Links are keyboard-focusable by default and activate with Enter.
- Never remove focus outline without replacing it with a visible focus style.
- Link text should be descriptive (avoid โclick hereโ).
Good vs bad:
<!-- Bad -->
<a href="mailto:someone@example.com">Click here</a>
<!-- Good -->
<a href="mailto:someone@example.com">Email Support</a>
7. Anchor vs Button โ When to use what?
- Use
<a>for navigation (go to a new page, external link, fragment). - Use
<button>for actions on the current page (open modal, submit form, toggle UI).
Bad pattern:
<a href="#" onclick="submitForm()">Submit</a> <!-- โ -->
Better:
<button type="button" onclick="submitForm()">Submit</button> <!-- โ
-->
8. download attribute (force download suggestion)
<a href="/files/resume.pdf" download>Download Resume</a>
<a href="/files/resume.pdf" download="Himanshu-Bhatt-Resume.pdf">Download</a>
Browser may still open the file depending on type & user settings, but download suggests saving.
9. Mailto links โ more details & extras
Basic mailto:
<a href="mailto:someone@example.com">Email me</a>
Multiple recipients:
<a href="mailto:person1@example.com,person2@example.com">Email both</a>
Add subject and body (URL-encoded):
<a href="mailto:someone@example.com?subject=Hello%20from%20site&body=Hi%20there%2C%0A%0AI%20found%20your%20site.">
Email with subject
</a>
- Spaces โ
%20 - New lines โ
%0Aor%0D%0A - Use
?for first param,&for others
Note: mailto opens the userโs email client. Not all desktop users have a configured client.
10. Tel links โ formatting & best practice
Basic:
<a href="tel:+911234567890">+91 12345 67890</a>
- Use international format (
++ country code) inhref. - Display can show spaces or local formatting for readability.
-
tel:opens dialer on mobile; desktop behavior varies.
Good examples:
<!-- Display friendly, href machine-friendly -->
<a href="tel:+14155552671">+1 (415) 555-2671</a>
<a href="tel:+911234567890">+91 12345 67890</a>
11. Usability & accessibility tips for mail/tel links
- Make link text descriptive:
Email SupportorCall Support. - For phone numbers, consider adding
aria-labelfor clarity:
<a href="tel:+911234567890" aria-label="Call support at +91 12345 67890">
+91 12345 67890
</a>
- Donโt rely on
mailto:for forms that require structured data โ prefer actual contact forms for reliability and spam protection.
12. Common mistakes (summary)
- Forgetting to add
rel="noopener noreferrer"withtarget="_blank". - Using links for actions that should be buttons (accessibility & semantics).
- Using
href="#"โ this is an anti-pattern (it changes the URL or scrolls). - Poor link text like โclick hereโ โ not descriptive for screen reader users.
- Not testing
mailto:/tel:behavior on mobile vs desktop.
โ ๏ธ Challenges / Mistakes I Faced
When I started, I used links for things that should be buttons and I often forgot rel="noopener noreferrer" for target="_blank".
I also learned that mailto: and tel: work great on mobile but may behave differently on desktop.
If you faced any issues or have questions, feel free to let me know in the comments ๐
๐ฌ Feedback & Discussion
๐ก Iโd love your feedback!
If you notice:
- something incorrect,
- a better explanation,
- or have suggestions to improve my understanding,
please comment below. Iโm happy to learn and correct mistakes.
โญ Support the Learning Journey
If you find these notes useful:
โญ Consider giving the GitHub repo a star โ
it really motivates me to keep learning and sharing publicly.
๐ฆ Stay Updated (Twitter / X)
I share learning updates, notes, and progress regularly.
๐ Follow me on Twitter/X:
๐ Whatโs Next
In the next post, Iโll be covering:
๐ Internal Page Navigation
Iโll also continue updating the GitHub repo as I progress.
๐ Final Thoughts
Thanks for reading!
If youโre also learning HTML, feel free to:
- follow along,
- share your experience,
- or drop questions in the comments ๐
๐ Learning in public
๐ Repo: https://github.com/dmz-v-x/html-101
๐ฆ Twitter/X: https://x.com/_himanshubhatt1
๐ฌ Feedback welcome โ please comment if anything feels off
โญ Star the repo if you find it useful
Top comments (0)