HTML Links Guide

Learn how to create effective, accessible hyperlinks in HTML

Introduction to HTML Links

Hyperlinks are the foundation of web navigation, connecting documents and resources across the internet. The HTML <a> (anchor) element creates hyperlinks that can point to:

  • Other web pages (internal or external)
  • Specific sections within a page
  • Files to download
  • Email addresses and phone numbers
  • JavaScript functionality

Well-structured links are essential for usability, accessibility, and search engine optimization. This guide covers all aspects of creating effective HTML links.

<a>

The anchor element creates hyperlinks

<a href="https://www.example.com">Visit Example</a>

Attributes: href (required), target, rel, download

Usage: For navigation between pages or resources

Absolute URLs

Links to external resources with full URL

<a href="https://www.example.com/about">About Us</a>

Usage: Linking to other websites

Relative URLs

Links to internal resources with relative paths

<a href="/about.html">About Page</a>

Usage: Linking within the same website

Download Links

Triggers file download instead of navigation

<a href="/files/document.pdf" download>Download PDF</a>

Attributes: download (optional filename)

Usage: For PDFs, documents, or other downloadable files

target

Specifies where to open the linked document

Values: _blank, _self, _parent, _top

Notes: Use with rel='noopener noreferrer' for security

rel

Relationship between current and linked document

Values: nofollow, noopener, noreferrer, external

Notes: Important for SEO and security

download

Indicates the link should download a resource

Values: Boolean or filename

Notes: Only works for same-origin URLs

aria-label

Accessible name for screen readers

Values: Descriptive text

Notes: Essential for icon-only links

Navigation Menu

Semantic navigationARIA labelsCurrent page indication

Footer Links

External linksSocial iconsAccessibility

Call-to-Action Buttons

Styling as buttonsPhone/email linksIcon integration

Link Text Clarity

Use descriptive link text that makes sense out of context

Recommended

Not Recommended

Why: Screen readers often list links out of context

External Link Security

Secure external links that open in new tabs

Recommended

Not Recommended

Why: rel='noopener noreferrer' prevents security vulnerabilities

Accessible Icon Links

Make icon-only links accessible

Recommended

Not Recommended

Why: Icon-only links need text alternatives

Styling Considerations

Ensure links are visually distinguishable

Recommended

Not Recommended

Why: Links should be obviously clickable

Fragment Identifiers

Linking to specific page sections

Use Case: For long pages with multiple sections

JavaScript Enhanced Links

Adding click handlers while maintaining accessibility

Use Case: When adding custom behavior to links

Protocol-Relative URLs

Links that adapt to http/https automatically

Use Case:
Note: Use with caution - modern best practice is to always specify https://

Links Playground

Experiment with different types of HTML links in our live editor

Link Examples Preview

Ready-to-use examples covering different link scenarios

Live Preview

Link Types Included

Basic Links
Internal/External
Bookmarks
Page sections
Email/Tel
Contact links
Download
File resources

All examples will be loaded into an interactive editor where you can modify and test them

< PreviousNext >