Skip to content
AgileLogics

HTML Link Code Generator

Generates an HTML <a> tag for a URL, with an optional link text and "open in new tab" attributes.

Working on a whole file? Open it in the HTML editor →

How it works

Enter a URL, optionally set link text and new-tab, then click Generate.

What does an HTML link generator do?

An HTML link generator writes the anchor element, <a href="…">text</a>, that turns words on a page into a clickable link. This one takes a URL, optional link text and an optional "open in new tab" setting, escapes the characters that would break the markup, and returns a single line of HTML you can paste into a page, email template or CMS source view.

Three outputs, side by side

Each line below was produced by the tool:

<a href="https://example.com/">https://example.com/</a>
<a href="https://example.com/docs?tab=api&amp;lang=en" target="_blank" rel="noopener noreferrer">API docs</a>
<a href="https://example.com/">Fish &amp; &lt;Chips&gt;</a>

The first had no link text, so the URL was used. The second had the link text API docs and Open in new tab ticked; note that the & between query parameters became &amp;, which is the correct way to write it inside an HTML attribute and is decoded back before the browser follows the link. The third had the text Fish & <Chips>, escaped so the angle brackets show as text instead of being read as a tag.

Escaping covers &, <, > and " in both the URL and the text. Spaces at either end of each field are trimmed. Nothing else changes, so the tool won't percent-encode spaces or non-ASCII characters inside the URL. If your address has those, run it through the URL encoder first.

How to create a link

  1. Paste the destination URL into the input.
  2. Type the link text, or leave it blank to show the URL.
  3. Tick Open in new tab if the link should open separately.
  4. Click Generate, then Copy.
  5. Paste the line into your HTML. To see how it renders first, paste it into the HTML viewer, which shows it in a sandboxed preview.

Attributes: what the tool adds and what you can add by hand

Attribute Added by the tool? What it does
href Always The destination. Google can only reliably crawl links that are <a> elements with an href
target="_blank" With the new-tab option Opens the link in a new tab or window
rel="noopener" With the new-tab option The new page gets no window.opener reference to yours
rel="noreferrer" With the new-tab option No Referer header is sent; also implies noopener
rel="sponsored" No Marks paid, affiliate or advertising links for Google
rel="ugc" No Marks links inside user-generated content
rel="nofollow" No Asks Google not to associate your site with the target
download No Downloads the file instead of navigating (same-origin URLs only)
hreflang No Hints at the language of the destination

Sources: MDN's <a> reference, MDN on noreferrer and Google's guide to qualifying outbound links. Several rel values can go in one attribute separated by spaces, for example rel="sponsored noopener noreferrer".

Think about noreferrer before you keep it. It's sensible for links to untrusted sites, but if you're linking to a partner who tracks referral traffic, removing it lets their analytics credit your page. noopener alone still keeps the security benefit.

Writing link text people and crawlers understand

Google's link best practices describe good anchor text as "descriptive, reasonably concise, and relevant" to both pages, and call out "click here" and "read more" as too generic. MDN gives the same advice for accessibility: screen-reader users often jump through a list of links, so each one should make sense on its own. "Download the 2026 rate card (PDF)" beats "here".

If you use the new-tab option, say so in the text. MDN recommends signalling links that open a new tab, for example by adding "(opens in new tab)", because an unexpected new window can confuse people using screen readers or magnification.

Things the generator doesn't stop

It won't reject a javascript: URL. Google's link guidance marks script-based href values as not recommended, and MDN recommends a <button> for anything that runs script rather than navigating. It also won't warn about a typo in the domain or a page that returns 404. After publishing, scan the page with the broken link checker.

Everything runs in your browser; the URL and text aren't sent anywhere. For more on how links and other elements fit together, the HTML lessons cover the basics.

Last updated

Frequently asked questions

Why does the new-tab option add rel="noopener noreferrer"?
Noopener stops the page you open from controlling your page through window.opener. MDN notes that newer browsers already apply that protection to target="_blank" links, so it mainly covers older browsers. Noreferrer additionally stops the browser sending a Referer header, so the destination's analytics won't see your page as the source.
Can it add nofollow, sponsored or ugc?
No. The tool's only attributes are href, plus target and rel when you tick the new-tab box. Add the value yourself inside the rel attribute. Google asks for sponsored on paid or affiliate links, ugc on user-generated links such as comments, and nofollow when neither applies and you don't want your site associated with the target.
What happens if I leave the link text empty?
The URL itself becomes the link text. That works for footnotes and reference lists, but MDN and Google both recommend descriptive link text that makes sense out of context, so it's usually better to write a few words describing the destination.
Does the tool check that my URL works?
No. It escapes the URL and wraps it in an anchor tag without visiting it or validating the format. Relative paths, mailto and tel links all pass through unchanged. To test links on a live page, use a broken link checker.