HTML Link Attributes

HTML link attributes provide additional information and control how hyperlinks behave. They are commonly used with the <a> element to define the destination of a link, specify where it opens, describe the relationship between pages, and control downloading behavior.

The most commonly used HTML link attributes include href, target, download, rel, and title. Understanding these attributes helps you create useful, accessible, and well-structured links.

If you are new to HTML attributes, first learn about HTML Attributes and then explore HTML Links.

The href Attribute

The href attribute specifies the destination of a link. It is the most important attribute used with the <a> element.

Example

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

The browser uses the value of href to determine where the user should be taken.

You can also use relative URLs:

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

Learn more about complete web addresses in HTML Absolute URLs and HTML Relative URLs.

The target Attribute

The target attribute specifies where the linked document should open.

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

The _blank value usually opens the link in a new browsing context.

Other common target values include:

_self
_blank
_parent
_top

For more details, see HTML Link Targets.

The download Attribute

The download attribute tells the browser that the linked resource is intended to be downloaded.

<a href="guide.pdf" download>
    Download Guide
</a>

You can also provide a suggested filename:

<a href="guide.pdf" download="html-guide.pdf">
    Download Guide
</a>

The final behavior can depend on browser settings and server configuration.

Learn more about this feature in HTML Download Links.

The rel Attribute

The rel attribute describes the relationship between the current webpage and the linked resource.

For example:

<a href="https://example.com"
   target="_blank"
   rel="noopener">
    Visit Example
</a>

Common rel values include:

ValuePurpose
noopenerHelps prevent the new page from accessing the opener
noreferrerPrevents the browser from sending the referrer in the request
nofollowIndicates that the link should not be treated as an endorsement for search purposes
externalIndicates that the linked resource is external

Multiple values can be specified by separating them with spaces:

<a href="https://example.com"
   rel="noopener noreferrer">
    Visit Example
</a>

The title Attribute

The title attribute can provide additional information about a link.

<a href="about.html" title="Learn more about our website">
    About Us
</a>

Depending on the browser and device, this information may appear as a tooltip when the user points to the link.

However, title should not be used as a replacement for clear and descriptive link text.

The hreflang Attribute

The hreflang attribute can indicate the language of the linked resource.

<a href="/es/about.html" hreflang="es">
    About Us in Spanish
</a>

Here, es indicates that the linked page is in Spanish.

This can be useful when a website provides different language versions of its content.

The type Attribute

The type attribute can provide a hint about the media type of the linked resource.

<a href="document.pdf" type="application/pdf">
    Download PDF
</a>

The value describes the MIME type of the destination resource.

HTML Link Attributes Example

You can combine several link attributes in one anchor element:

<a href="https://example.com"
   target="_blank"
   rel="noopener"
   title="Visit Example Website">
    Visit Example
</a>

Here, href specifies the destination, target controls where it opens, rel describes the relationship, and title provides additional information.

Best Practices for HTML Link Attributes

Use href for the correct destination, choose target based on the intended browsing behavior, and use rel when the relationship between pages needs to be specified.

Use descriptive link text instead of depending on the title attribute to explain a link. For downloadable resources, use the download attribute when appropriate.

Understanding HTML link attributes gives you greater control over hyperlinks and helps you build clear, functional, and accessible website navigation.