
The anchor element is one of the most important elements in HTML. It is what makes the web a web, connecting billions of pages across the internet. While creating a basic link is simple, the anchor element offers several attributes that control how links behave, how secure they are, and how accessible they are to all users. This tutorial provides an in-depth look at how to link one web page to another in HTML, covering syntax, attributes, path types, and professional best practices.
Clean, Standards-Compliant Code From AAMAX.CO
Writing clean, semantic HTML is the foundation of every high-quality website. AAMAX.CO is a full-service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their developers write standards-compliant, accessible code that performs well across browsers and devices. Every link, menu, and interactive element they build follows best practices, helping businesses deliver smooth user experiences and strong search engine performance.
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 a element defines the link, href defines the destination, and the text between the tags is what users click.
The href Attribute
The href attribute is required for a functional link. It can contain a relative path like about.html, a root-relative path like /about.html, an absolute URL like https://example.com/about, a fragment like #contact, or special schemes like mailto: and tel:. Choosing the right path type depends on whether the destination is internal, external, or on the same page.
The target Attribute
The target attribute specifies 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://example.com" target="_blank" rel="noopener noreferrer">Example</a>Use _blank primarily for external resources, and avoid overusing it for internal navigation.
The rel Attribute
The rel attribute describes the relationship between the current page and the linked page. Common values include noopener and noreferrer, which improve security and privacy for links opening in new tabs. The nofollow value tells search engines not to pass ranking signals to the linked page, while sponsored and ugc identify paid links and user-generated content. Using rel correctly supports both security and SEO compliance.
The download Attribute
The download attribute instructs the browser to download the linked file instead of navigating to it:
<a href="/files/brochure.pdf" download>Download Brochure</a>You can optionally provide a file name as the attribute value. This works for files hosted on the same origin.
The title Attribute
The title attribute adds supplementary information that appears as a tooltip on hover. However, it is not reliably accessible to keyboard, touch, or screen reader users, so never rely on it to convey essential information. Descriptive link text is always the better choice.
Relative Paths in Detail
Relative paths are based on the location of the current file. A file name alone refers to the same folder. A folder name followed by a slash and file name refers to a subfolder. Two dots followed by a slash move up one directory. Mastering these patterns allows you to link pages correctly in any folder structure.
Styling Links With CSS
CSS pseudo-classes let you style link states:
a { color: #c2410c; }a:hover { text-decoration: underline; }a:focus-visible { outline: 2px solid currentColor; }Always maintain visible focus styles and sufficient color contrast so links remain accessible.
Semantic and Accessible Linking
Use anchor elements for navigation and button elements for actions that do not change the page, such as opening a modal. Write descriptive link text, provide alt text for linked images, and ensure links can be reached and activated with a keyboard. These practices are essential in professional website design and development.
Common Mistakes to Avoid
Avoid empty href values, broken paths, links without meaningful text, and nested anchor elements, which are invalid HTML. Double-check file names for typos and case sensitivity, since many web servers treat About.html and about.html as different files.
Putting It All Together
Here is a well-formed internal link that combines several best practices: a descriptive label, a root-relative path, and no unnecessary attributes.
<a href="/services/website-design.html">Explore our website design services</a>And here is a well-formed external link that opens safely in a new tab and signals the behavior to users:
<a href="https://developer.mozilla.org/" target="_blank" rel="noopener noreferrer">MDN Web Docs (opens in a new tab)</a>Practicing with these patterns builds habits that keep your code clean and your links reliable across every page you create. Before publishing, validate your HTML with a free markup validator to catch unclosed tags, invalid nesting, and malformed attributes. Validation is a quick step that prevents subtle bugs and ensures consistent behavior across browsers, especially as your website grows to include dozens or hundreds of interlinked pages.
Conclusion
Linking one web page to another in HTML involves more than writing an anchor tag. Understanding href, target, rel, download, and title attributes gives you precise control over link behavior. Master relative paths, style links accessibly, use semantic elements correctly, and avoid common mistakes. With these skills, you can create links that are secure, accessible, and optimized for both users and search engines.
