An HTML link (hyperlink) connects the current page to another resource. You create one with the <a> element. The href attribute holds the destination; the content inside <a>—text, an image, or other phrasing content—is what visitors click.
What can a link point to?
Another HTML page, a PDF or download, an email address (mailto:), a phone number (tel:), or a section on the same page via a fragment (#id). Absolute URLs name a full address; relative URLs navigate within your own site.
Why links matter
Links are the spine of the web. Clear link text, correct paths, and thoughtful target / rel choices make navigation predictable for everyone—including keyboard and screen-reader users.
When should you use them?
Anytime someone needs to leave the current view for related content, contact you, jump to a heading, or open a resource in a new tab. Prefer descriptive labels over “click here.”
The <a> element.
Without a valid href, an <a> is not a hyperlink—it is just a placeholder. Always set href for real navigation.
New tabs need rel.
When you use target="_blank", add rel="noopener noreferrer" so the new page cannot access window.opener.
Link text should describe the destination.
Screen readers often list links out of context. Phrases like “HTML Lists tutorial” beat “read more.”
Syntax
HTML Link Syntax
The basic form:
link.html
<ahref="url" >Link text</a>
HTML
<!-- Absolute URL -->
<a href="https://www.example.com">Example site</a>
<!-- Relative URL -->
<a href="about.html">About us</a>
<!-- Open in a new tab -->
<a href="https://www.example.com" target="_blank" rel="noopener noreferrer">Example (new tab)</a>
<!-- Fragment / bookmark -->
<a href="#faq">Jump to FAQ</a>
<!-- Email -->
<a href="mailto:[email protected]">Email us</a>
<!-- Tooltip -->
<a href="guide.html" title="Open the beginner guide">Guide</a>
Common attributes: href (required for a real link), target (_self, _blank, and others), rel, title, and download for file saves.
Reference
Core HTML Concepts
Ideas that keep hyperlinks correct and usable:
Concept
Meaning
<a href="…">
Creates a hyperlink to the given URL
Absolute URL
Full address with scheme and host (https://…)
Relative URL
Path resolved from the current page (page.html, ../docs/)
target="_blank"
Opens the destination in a new tab or window
target="_self"
Default—navigates in the same browsing context
Fragment (#id)
Scrolls to an element with a matching id on the page
mailto:
Opens the user’s email client with a prefilled address
title
Advisory tooltip text on hover (not a substitute for visible labels)
Absolute vs relative
Absolute
Relative
Example
https://codetofun.com/html
lists.html or /html/lists
Best for
External sites
Pages inside your project
Breaks if site moves?
Only if the remote host changes
Can break if folder structure changes
Approach
How to Use Links in HTML
Practical habits for clear, safe navigation.
Write <a href="…">descriptive text</a> where navigation belongs.
Prefer relative paths for your own pages; use absolute URLs for other sites.
Add target="_blank" only when a new tab helps—and always include rel="noopener noreferrer".
For same-page jumps, set an id on the target and link with href="#id".
Use mailto: for contact links; wrap images in <a> when the graphic is the control.
Keep title optional and short—visible text remains primary.
<a href="…"> creates a hyperlink; descriptive text (or alt on image links) names the destination.
Absolute vs relative URLs: full host for externals, paths for your own site.
target="_blank" needs rel="noopener noreferrer"; default is _self.
Fragments, mailto, and image links extend the same <a> pattern.
One line: Write <a href="destination">clear label</a>, choose absolute or relative URLs wisely, and harden new tabs with rel.
Frequently Asked Questions
An HTML link (hyperlink) is created with the a element. Its href attribute names the destination—another page, a file, an email address, or a section on the same page. Visitors click the link text or nested content to navigate.
Write <a href="url">link text</a>. Replace url with an absolute address (https://…), a relative path (about.html), a fragment (#section), or a mailto: address.
An absolute URL includes the scheme and host (https://example.com/page). A relative URL is resolved against the current page’s location (page.html or ../docs/guide.html). Use relative paths for links inside your own site.
Use target="_blank" to open the destination in a new browsing context (usually a new tab). Pair it with rel="noopener noreferrer" for security and privacy. Prefer _self (the default) when the user should stay in the same tab.
Give the target element an id, then set href="#that-id". Clicking the link scrolls to that element. These are called bookmark or fragment links.
Yes. Wrap an img element inside an a element. The image becomes the clickable surface. Always keep a meaningful alt on the image so assistive tech can describe the link destination.