HTML Link Generator

Builds an anchor tag with the rel value a new tab needs, the attributes screen readers use, and nothing that only looks like good practice.

Enable JavaScript to customise; default output below.

A relative path works too. A bare domain without a scheme is treated as a relative path by every browser, which is the commonest broken link there is.

What the link does, in words that make sense read on their own. "Click here" and "read more" fail that test, and a screen reader user often hears only the link text.

Set noopener with a new tab. nofollow for a link you do not vouch for, sponsored for a paid one, ugc for user-submitted. noreferrer also hides the referrer, which breaks the other site's analytics.

Added inside the link when it opens a new tab, so the announcement mentions it. Only used with the new tab option.

Usually the wrong tool: it does not appear on touch devices, is inconsistently announced, and duplicating the link text in it adds nothing.

Replaces the link text for assistive technology, so it has to include the visible words. Leave it empty unless the link text genuinely cannot say enough.

Live preview link.html
<a href="https://example.com/pricing">See the pricing</a>

Output is valid and updates as you type.

Two things about an anchor tag are worth getting right, and the rest is typing.

target="_blank" needs rel="noopener". Without it, the page you open gets a reference to yours through window.opener and can navigate it somewhere else. Modern browsers imply noopener for target="_blank" now, and writing it anyway costs nothing and covers the older ones still in use.

And a link that opens a new tab should say so. The reader loses the back button, which is the thing they know how to use, and a screen reader announces nothing about it unless you put it in the link. A hidden span inside the link is how that is normally done.

How to use

  1. Put in the URL and the link text. The text is the part that matters.
  2. Tick the new tab box only if there is a reason, and set rel to noopener when you do.
  3. Add nofollow, sponsored or ugc to rel if the link is one you do not vouch for.

Example

The default is the whole tag when nothing special is needed:

<a href="https://example.com/pricing">See the pricing</a>

A paid external link in a new tab, with the announcement:

<a href="https://partner.example.org/offer?ref=us"
   rel="noopener nofollow"
   target="_blank"
   class="link link--external">Read the partner's terms<span class="screen-reader-text"> (opens in a new tab)</span></a>

Everything is escaped on the way in, so a quote or an angle bracket in any field becomes an entity rather than an attribute:

<a href="https://example.com/search?q=a&amp;b=&quot;1&quot;&amp;c=&lt;2&gt;"
   class="a&quot; onmouseover=&quot;alert(1)">O&#39;Brien&#39;s &quot;quoted&quot; &lt;/a&gt;</a>

Pitfalls

“Click here” is not link text. A screen reader can list the links on a page, and a list of “click here” tells the user nothing. Write what is on the other side: “See the pricing”, “Download the 2026 price list”.

New tabs are a decision made for the reader. They break the back button and multiply windows. Anyone who wants a new tab can middle-click or use the context menu, and they know that. There are reasons to do it, mostly forms in progress and documentation opened alongside, and “it keeps them on our site” is not one.

title is almost never the answer. It does not appear on touch devices, screen readers treat it inconsistently, and repeating the link text in it adds nothing. If information is needed, put it in the visible text.

aria-label replaces the link text for assistive technology. So it must contain the visible words, or a voice-control user asking for “click See the pricing” fails. Leave it empty unless the text genuinely cannot carry the meaning.

download only works same-origin. On a cross-origin URL the browser ignores it and navigates, and the download attribute cannot rename a file you do not serve.

rel="noreferrer" hides your referrer too. That breaks the other site’s analytics and your own attribution of outbound traffic. noopener alone does the security job.

A bare domain without a scheme is a relative path. href="example.com" points at yoursite.com/example.com, which is the commonest broken link on the web. Include https://.

nofollow, sponsored and ugc are different claims. sponsored for paid placement, ugc for user-submitted content, nofollow for a link you simply do not endorse. Search engines ask for the specific one, and using nofollow for everything is accepted and less informative.

Compatibility

Everything runs in the browser: nothing is uploaded and nothing is stored.

Every value is HTML-escaped, so quotes, angle brackets and ampersands become entities and cannot break out of the attribute. The hostile fixture in the test suite includes a class value crafted to inject an event handler, and the expected output shows it inert.

Attributes are omitted entirely when their field is empty rather than written as class="", so the output is the tag you would have written by hand.

rel="noopener" is implied by browsers for target="_blank" since 2021 in Chrome, Firefox and Safari. Writing it explicitly matters for older browsers and for anything embedded in a webview, and it documents the intent for the next person reading the markup.

The download attribute works in every current browser, same-origin only, and is ignored elsewhere. The screen-reader-text class is the WordPress convention; if your theme does not define it, any visually-hidden utility class will do, and the hidden text must not be set to display: none, which removes it from the accessibility tree as well.

Frequently asked questions

Do I still need rel=”noopener”?
Not for current browsers with target="_blank", which imply it. Write it anyway: it is one word, it covers older browsers and webviews, and it states the intention.
Should links open in a new tab?
Usually no. Do it when leaving the page would lose work, such as a part-completed form, and say so in the link when you do.
How do I mark an affiliate link?
rel="sponsored", or rel="sponsored nofollow" if you want both. It is a disclosure to search engines and it is not a substitute for the disclosure your readers and the regulator need.
What is the difference between aria-label and title?
aria-label replaces the accessible name and is reliably supported. title produces a tooltip on hover only, is unavailable on touch, and is announced inconsistently. Prefer visible text to either.
Is <a> without href valid?
It is valid and it is not a link: it is a placeholder. It is not focusable or clickable by keyboard, so if something needs to be interactive without navigating, use a button.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.