Hyperlink

On this page 8

A hyperlink is a reference in a document that a user can activate to navigate to another resource or location, and in HTML it is created primarily with the anchor element (a) and its href attribute. Hyperlinks are the mechanism that turns separate documents into the interconnected web, because every page can point to any other addressable resource by its URL.

On the Web, a hyperlink carries more than a destination. It also has link text that tells people and search engines what to expect, optional relationship metadata such as rel, and behavior that browsers, assistive technologies and crawlers interpret in standardized ways defined by the HTML Living Standard.

A hyperlink works by pairing a clickable element with a target address that the browser resolves and loads when the link is activated. The minimal form is <a href="/pricing">Pricing</a>, where the href value is the target and the enclosed content is the accessible name of the link.

When a user clicks, taps or presses Enter on a focused link, the browser resolves the URL against the document base, applies any target and rel rules, and starts a navigation. An a element without href is only a placeholder: it is not focusable by default and does not behave as a link.

The table below lists the main parts of an anchor element and their role.

ComponentExamplePurpose
href attributehref="/docs/setup"Defines the destination URL
Link textSetup guideDescribes the destination to users
target attributetarget="_blank"Chooses the browsing context
rel attributerel="noopener"States the relationship to the target
download attributedownload="report.pdf"Requests a file download
hreflang attributehreflang="de"Indicates the target language
Components of an HTML anchor element

Hyperlinks differ by what kind of address they use and where they lead. The distinction matters for maintenance, because relative links survive domain changes while absolute links remain valid when content is copied elsewhere.

TypeExample hrefTypical use
Absolute URLhttps://example.org/aboutLinks to external sites
Root-relative URL/blog/Internal links on the same site
Document-relative URL../images/map.htmlLinks within a folder structure
Fragment link#installationJumps to an element with that id
Email linkmailto:support@example.orgOpens the default mail client
Telephone linktel:+15551234567Starts a call on mobile devices
Common hyperlink types

A fragment identifier points to an element whose id matches the text after the hash sign, which makes it the standard technique for tables of contents and skip links. Modern browsers also support text fragments, which highlight a quoted passage in the target page, although support and behavior still vary between engines.

A hyperlink is meant for navigation, and several other HTML features look similar but serve different purposes. Confusing them harms accessibility, because assistive technologies announce each control by its role.

FeaturePrimary purposeWhen to choose it
Anchor with hrefNavigate to a URLThe user goes somewhere new
Button elementTrigger an actionThe user submits, opens or toggles
Link element in headDeclare document relationshipsStylesheets, canonical, preload
Form submissionSend data to a serverSearch, login, checkout
Image map areaLink regions of an imageClickable diagrams or maps
Hyperlinks versus similar controls

The key rule is simple: use a link to change the URL and use a button for actions. Styling a div with a click handler to imitate a link removes keyboard focus, the context menu and the ability to open the target in a new tab. An a element is an inline element by default, although in HTML5 it may wrap block content such as a whole card.

The rel attribute, security and search engines

The rel attribute tells browsers and crawlers how the current page relates to the linked resource. Several values have direct effects on security, privacy and search ranking, so they are part of everyday web development rather than optional extras.

ValueEffectTypical context
noopenerBlocks access to window.openerLinks opening a new tab
noreferrerOmits the Referer header and implies noopenerPrivacy-sensitive outbound links
nofollowAsks crawlers not to pass ranking signalsUntrusted or unendorsed links
sponsoredMarks paid or affiliate linksAdvertising and partnerships
ugcMarks user-generated contentComments and forum posts
Frequently used rel values on hyperlinks

Opening a page with target="_blank" once exposed the original tab to reverse tabnabbing, in which the new page could redirect its opener. Current browsers apply noopener by default for such links, yet adding it explicitly remains good practice for older clients. For search engines, descriptive anchor text is a strong relevance signal, while generic text such as “click here” gives neither users nor crawlers useful context.

An accessible hyperlink makes its purpose clear from the link text alone or from its immediate context, as required by WCAG success criterion 2.4.4. Screen reader users often browse a page as a list of links, so ten links reading “read more” become indistinguishable.

  • Write descriptive link text that names the destination or result.
  • Keep a visible focus indicator so keyboard users know where they are.
  • Do not rely on color alone to mark links inside body text; an underline is the clearest cue.
  • Warn users about new tabs or downloads, for example by noting the file type and size.
  • Provide adequate target size, particularly on touch screens.

Images used as links need meaningful alternative text that describes the destination, not the picture. A logo linking to the home page, for instance, should announce the site name and home page rather than “logo”.

Hyperlinks decay over time because target pages move or disappear, a problem known as link rot. Regular link checking, permanent redirects with HTTP status 301 and stable URL design keep a site navigable and protect its search visibility.

Other frequent errors include using href="#" with JavaScript for actions, which should be buttons, and nesting interactive elements inside a link, which the specification forbids. Breaking the back button with scripted navigation and hiding destinations behind tracking redirects also reduce user trust.

The idea in brief

A hyperlink is the clickable text or image that takes you from one page to another. It works like a signpost: the words tell you where it leads, and the hidden address behind it tells the browser exactly where to go.

Every time you click a blue underlined word, open a menu item or jump to a section further down a page, you are following a hyperlink. Links are what connect separate pages into one web, and good links always make clear where you will end up.

A practical scenario

A university library redesigns its research guides, which contain about 1,200 links to databases, journals and internal help pages. An audit with a link checker finds that 14 percent of links are broken and that many use the text “click here”, which screen reader users report as confusing.

The web team rewrites link text to name each resource, replaces hard-coded absolute addresses for internal pages with root-relative paths, and adds rel="noopener" to links that open external databases in new tabs. Long guides gain a table of contents built from fragment links to each heading.

After the update, broken links fall to under one percent, navigation tests with keyboard users succeed without assistance, and the team schedules a monthly automated check. The result is a more reliable and accessible set of guides that requires far less manual correction.