Link Relations
How the rel attribute says what a link is for, which values Vanilla Breeze styles, and what it does to links that open a new tab.
Say what the link is for
The rel attribute on a link names its relationship to the current page: it leads off the site, it is the next chapter, it is the license, it is a topic. HTML already defines these words. Vanilla Breeze styles several of them, so a link that states its purpose needs no class to look the part.
<a href="/topics/bread" rel="tag">Bread</a><a href="/handbook/proving-times" rel="external">shared proving chart</a><a href="/glossary" rel="help">baking terms</a><a href="/chapter-4" rel="prev">Chapter 4: Shaping</a><a href="/chapter-6" rel="next">Chapter 6: Scoring and baking</a><a href="/license" rel="license">Licensed CC BY 4.0</a>
Values with a style
| Value | Meaning | Style |
external | The destination is on another site | A trailing ↗ |
tag | A topic that applies to this page | A pill outline |
prev | The previous page in a series | A leading ← |
next | The next page in a series | A trailing → |
help | Help for this page or control | A dotted underline |
license, privacy-policy, terms-of-service | Legal pages | Slightly smaller and fainter |
The arrows are decoration. They are given empty alternative text, so a screen reader reads the link text alone.
Where the arrows do not appear
Inside <nav>, <header> and <footer> the external, prev and next arrows are turned off, because a navigation bar full of arrows is noise. A previous and next pair inside a <nav> therefore shows no arrows. If you want them, put the pair in a <p> or a layout element, as the demo does, or add the arrows yourself with <icon-wc>.
The pill, the dotted underline and the fainter legal links apply everywhere.
External links without rel
A link whose href starts with http or // gets the same ↗ without any rel. Downloads, mailto:, tel: and PDF links get their own marks the same way. Add rel="external" when the address alone does not show that the link leaves the site, such as a redirect path on your own domain, or when you want other tools to know. A link with both gets one arrow. Add data-no-icon to a link to remove its mark.
Values without a style
These carry meaning for browsers, search engines and your own selectors. The library gives them no look.
| Value | Meaning |
nofollow | Do not treat the link as an endorsement |
author | A page about the author. In the <head>, <link rel="author"> is read by <page-info>. |
me | Another page that represents the same person |
bookmark | A permanent link to the nearest <article> |
search | A search page for this site |
alternate | Another form of this page. Pair it with hreflang for a translation or type for another format. |
a[rel~="bookmark"] { color: var(--color-text-muted); text-decoration: none;}
Use ~= in the selector. rel is a list of words, and [rel="tag"] would miss rel="tag nofollow".
Links that open a new tab
A page opened with target="_blank" can reach back to the page that opened it unless the link says noopener. When a page contains such a link, the library loads a small module that adds rel="noopener" to every <a target="_blank"> that does not already state a policy with opener, noopener or noreferrer. Press the button in the demo above to read the attribute it added.
<a href="https://example.com/ovens" target="_blank">Oven supplier</a> <a href="https://example.com/ovens" target="_blank" rel="noopener">Oven supplier</a>
- Write
rel="opener" on a link that needs the connection, and it is left alone.
- Links in the page when the module loads are changed at once. A link added later gets the attribute when the reader activates it, by click, keyboard or middle click, before the browser follows it.
- Current browsers already treat
target="_blank" as noopener. The attribute makes the policy explicit in the markup.
Hiding the referrer
Set data-link-privacy="strict" on <html> and the same pass also adds noreferrer to every new-tab link, so the destination is not told which page the reader came from. It is off by default because referral reports and affiliate links depend on that header.
<html lang="en" data-link-privacy="strict">...<a href="https://example.com/ovens" target="_blank">Oven supplier</a>
Choosing between rel, class and data attributes
| You want to say | Use | Example |
| What the link is, in relation to this page |
rel, with a value HTML defines |
rel="next" |
| How the link should look |
data-variant or a class |
data-variant="muted", data-variant="plain" |
| Something your own scripts need |
A data-* attribute |
data-track="pricing-click" |
Do not invent rel values for styling or tracking. Other tools read rel and expect its words to mean what the standard says.
<a href="/checkout" rel="primary-cta track-checkout">Buy now</a> <a href="/checkout" class="button" data-track="checkout">Buy now</a>
Finding links by purpose
Because the purpose is in the markup, a script can collect links by it with a selector. No helper is needed.
const topics = [...document.querySelectorAll('a[rel~="tag"]')] .map((link) => link.textContent.trim());