
HTML links are deceptively simple. At their core, they require only a single element and attribute, yet the anchor tag offers a range of options that control how links behave, how secure they are, and how accessible they are to all users. If you want to go beyond the basics and truly understand how to link one web page to another in HTML, this guide provides a detailed look at the anchor element, its attributes, and the best practices professional developers follow.
AAMAX.CO: Clean, Standards-Compliant HTML Development
Professional websites are built on clean, semantic, and standards-compliant HTML. AAMAX.CO is a full-service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their developers write accessible, well-structured code that performs reliably across browsers and devices. Businesses seeking robust, maintainable websites and applications can trust their web application development services to deliver solutions built on solid technical foundations.
The Anatomy of an HTML Link
An HTML link consists of an opening anchor tag, attributes, link content, and a closing tag:
<a href="services.html">Explore Our Services</a>The href attribute defines the destination, while the content between the tags is what users click. Link content can be text, images, or other inline elements.
The href Attribute in Detail
The href attribute accepts several types of values. A relative path such as about.html points to a page relative to the current file. A root-relative path such as /about.html starts from the website root. An absolute URL such as https://www.example.com/about includes the full address. A fragment such as #team points to an element on the same page. Special schemes like mailto: and tel: open email clients and phone dialers.
Working With Relative Paths
Relative paths are the preferred way to link pages within your own website. Consider this structure:
index.html
about.html
blog/
post.htmlFrom index.html, link to blog/post.html. From blog/post.html, link back with ../index.html. The ../ notation moves up one directory. Understanding this notation prevents most broken internal links.
The target Attribute
The target attribute controls where the linked page opens. The default value, _self, opens the page in the same tab. The value _blank opens it in a new tab or window:
<a href="https://www.example.com" target="_blank" rel="noopener noreferrer">External Resource</a>Use _blank mainly for external links or documents, as opening internal pages in new tabs can disorient users.
The rel Attribute
The rel attribute describes the relationship between the current page and the linked page. The value noopener prevents the new page from accessing the original page through JavaScript, improving security. The value noreferrer hides referrer information. For SEO, nofollow tells search engines not to pass ranking signals, while sponsored and ugc identify paid and user-generated links respectively.
The download Attribute
To prompt users to download a file instead of navigating to it, add the download attribute:
<a href="files/brochure.pdf" download>Download Brochure</a>You can provide a value to suggest a file name. This works for files hosted on the same origin as your website.
The title Attribute
The title attribute displays a tooltip when users hover over a link. While it can provide supplementary information, it should never replace descriptive link text, because tooltips are not reliably available to keyboard, touch, or screen reader users.
Linking Images
To make an image clickable, wrap it inside an anchor element:
<a href="index.html">
<img src="logo.png" alt="Company home page">
</a>The alt text should describe the link's destination or purpose, since it serves as the link text for assistive technologies.
Accessibility Best Practices
Accessible links benefit all users. Write descriptive link text that makes sense out of context. Ensure links are visually distinguishable from surrounding text, not by color alone. Maintain visible focus styles for keyboard navigation. Avoid empty links and links with duplicate vague text like read more without additional context.
Styling Links With CSS
Use CSS pseudo-classes to style link states: a:link for unvisited links, a:visited for visited links, a:hover for mouse hover, a:focus-visible for keyboard focus, and a:active while clicking. Thoughtful styling provides clear visual feedback and reinforces your brand.
Common Mistakes to Avoid
Avoid spaces and uppercase letters in file names, which can cause broken links on some servers. Double-check paths after moving files. Do not use JavaScript-only navigation when a simple anchor will work, as anchors are more accessible and SEO-friendly. Test every link before publishing.
Links Versus Buttons
A common question is whether to use an anchor element or a button element. The rule is simple: use an anchor when the action navigates to another page or location, and use a button when the action performs something on the current page, such as submitting a form or opening a dialog. You can style anchors to look like buttons, but keep the underlying element semantically correct so that assistive technologies announce it properly and keyboard behavior matches user expectations.
Conclusion
Linking one web page to another in HTML starts with the anchor element and href attribute, but mastering links means understanding paths, target, rel, download, and title attributes. Apply accessibility best practices, style link states clearly, and avoid common mistakes. With this knowledge, you can create links that are secure, user-friendly, and optimized for search engines.