Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How To Add A Backlink Using HTML Correctly (The Code, The Mistakes, The Fixes)

If you are skim reading
Straight answer: a correctly coded backlink is a plain anchor tag, written as <a href="https://example.

Straight answer: a correctly coded backlink is a plain anchor tag, written as <a href="https://example.com">your anchor text</a>, placed inside crawlable text on a live page, with the right rel attribute only if the link is paid, user-generated, or one you don't want to vouch for. Get the tag right, get the placement right, and stop worrying about the rest, because most of what people call "backlink HTML mistakes" are placement and trust problems dressed up as code problems.

The anchor tag, broken down

Every backlink on the web, no matter how fancy the tool that generated it, comes down to one line of HTML:

<a href="https://www.example.com/page">anchor text goes here</a>

That's it. Three parts matter:

  • The href attribute, which is the exact URL you're pointing to, ideally the full address including https:// so there's no ambiguity for crawlers.
  • The anchor text, which is what a reader clicks and what Google reads as a signal about what's on the other end.
  • Where that tag sits in the document, because a link buried inside a script tag or hidden behind CSS display:none isn't a backlink at all, it's a decoration.

I've had writers ask me if they need to add class names, data attributes, or special IDs to "help" the backlink work. You don't. A CMS like WordPress will often wrap your link in extra markup automatically, and that's fine, it doesn't dilute anything. The only attribute that changes meaning is rel, and I'll get to that.

Step by step, in raw HTML

Since ordered steps read cleaner as a plain list here, this is what I do when I'm adding a link inside a post's HTML or text editor:

  • Open the HTML or text editor view of your page (in WordPress, that's the Code Editor mode, not Visual).
  • Find the exact word or phrase you want to link, ideally two to four words that describe the destination.
  • Wrap it: <a href="https://www.destination-site.com/specific-page/">the phrase</a>.
  • Check the URL has no typos, trailing spaces, or a stray character copied from a PDF (this happens constantly with smart quotes pasted from Word).
  • Preview the page and click the link yourself before you publish, not after.

That last step sounds obvious and almost nobody does it. When I audit guest posts for clients using my digital marketing guest post search string to find placement opportunities, I'd say one in eight published guest posts has a broken or misdirected link, usually because someone pasted the wrong URL from a spreadsheet of ten links they were placing that week.

The rel attribute: when to use it, when to leave it alone

A plain anchor tag is a "dofollow" link by default. You don't need to write rel="dofollow", that's not a real attribute, it's just the absence of anything else. Where people get confused is the three rel values that change how Google treats a link:

  • rel="nofollow" tells search engines not to pass ranking credit through the link. Use it for comments, forum posts, or anything you don't control.
  • is for paid placements, affiliate links, or anything where money changed hands. Google introduced this in 2019 specifically so sites would stop hiding paid links behind plain nofollow.
  • rel="ugc" stands for user-generated content, meant for comment sections and forum signatures.

The full tag for a paid link looks like this: <a href="https://www.example.com" >anchor text</a>. If you're linking out to another blog because you rate their content, and no money or product changed hands, you leave rel off entirely.

Here's the uncomfortable bit nobody selling link building services likes to say out loud: Google's own John Mueller has confirmed publicly that nofollow is treated as a "hint" now, not a hard rule, meaning Google can and sometimes does still use nofollowed links as a ranking signal if the context is strong enough. So the rel attribute isn't the moral force field a lot of SEOs treat it as. Coding a link correctly matters far less than whether the linking page is one Google trusts in the first place. A perfectly formed dofollow anchor tag sitting on a spammy directory page with forty other outbound links does close to nothing. I'd rather have one nofollow link from a site like the BBC or a university press page than ten dofollow links from low quality guest post farms, and if you've read any of my traffic work, you'll know I mean that literally, not as a nice sentiment.

A real example from my own site

Two years ago I had a developer update a client's theme and, in the process, every internal and external link on the blog got rendered through a JavaScript click handler instead of a plain href, because it made an animated hover effect easier to build. It looked identical to a normal link. Visitors clicked it, it worked, nothing seemed wrong. But when I ran the site through a basic crawler, forty three backlinks we'd carefully placed for a client over the previous six months weren't being read by search engines at all, because there was no href attribute in the raw HTML, only an onclick event. Six months of outreach effort, invisible to Google.

We fixed it by adding a proper href alongside the JavaScript, so the link worked for both humans and crawlers: <a href="https://www.destinationsite.com/page/" onclick="doSomething(); return false;">anchor text</a>. That's the only "advanced" trick worth knowing here, and it exists purely to undo damage caused by developers who prioritise a hover animation over a working link.

Anchor text: the part people get wrong more than the code

The HTML tag can be flawless and the backlink can still hurt you if the anchor text is stuffed with exact-match keywords. If every backlink pointing at your "best CRM software" page says "best CRM software" word for word, that pattern looks manufactured to Google's algorithms, and it has triggered manual actions for sites I've reviewed. Natural anchor text mixes:

  • The brand or site name ("Lilach Bullock's guide")
  • A generic phrase ("this article", "worth reading", "more on this here")
  • A partial match ("keyword ranking tools" rather than the exact page title)
  • The full URL itself, occasionally, which reads as completely natural because that's how people paste links

If you're building out a resource page and want to understand how anchor text and link placement affect your rankings over time, it's worth tracking it rather than guessing, which is exactly why I wrote about how keyword ranking history helps your SEO strategy, because a single snapshot tells you nothing about whether a link moved anything.

Before you pitch, check this guest posting sites list for blogs that take submissions.

Position matters more than most HTML guides admit. A link in the first 100 words of a useful article carries more weight in practice than the same link buried in a footer or an author bio, because it sits inside content Google's systems associate with the topic. When I'm placing a client backlink in a guest post, I aim for:

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

  • Within the first third of the article, not the last paragraph
  • Inside a sentence that would make sense even if the link were removed, not a sentence built purely to hold the link
  • Surrounded by relevant text, not a random paragraph bolted on for the sake of it

This is also where a lot of "correct HTML" advice quietly falls apart. You can code the tag perfectly and still waste it by sticking it in a boilerplate author bio that gets copy-pasted across fifty guest posts with the same three sentences. Google's systems have gotten fairly good at spotting that pattern, and it's part of why link building that leans on volume over placement has stopped working the way it did five years ago. If you want more traffic from links, it comes from fewer, better-placed ones inside content people read, which is one of the points I make in 10 strategies that can double your website traffic.

Before you consider a backlink done, check three things:

  • View the page's source code (right click, "View Page Source" in most browsers) and search for your domain name to confirm the href exists in the raw HTML, not just visually on the page.
  • Click the link on a fresh browser tab, logged out of any accounts, to make sure it isn't accidentally geo-blocked or paywalled.
  • Run the URL through Google's URL Inspection tool inside Search Console if it's your own site, or simply search site:destinationurl.com in Google after a few days to confirm it's been indexed.

I do this for every guest post I place now, after the JavaScript incident. It takes ninety seconds. It has saved me from at least a dozen wasted placements since.

Common mistakes that quietly break backlinks

  • Linking to a URL with a trailing slash inconsistency that triggers a redirect chain instead of a direct link (https://site.com/page vs https://site.com/page/)
  • Using target="_blank" without rel="noopener", which is a security issue more than an SEO one, but still worth fixing since browsers and some CMS platforms flag it
  • Pasting a link with UTM tracking parameters into what should be a clean canonical link, which can confuse analytics and occasionally canonical signals
  • Linking to a page that later gets deleted or moved, leaving a 404 where your backlink used to point, something worth checking every few months rather than assuming a link placed in 2023 still resolves in 2026
  • Curly or "smart" quotes copied from Word or Google Docs breaking the href attribute entirely, which happens more than anyone admits

If you're publishing on a platform that lets contributors add their own social sharing buttons or plugins, it's also worth checking those don't inject extra rel attributes or redirect links through a third party domain without you realising, something I cover in my review of how to get more social shares with the Social Warfare plugin, since sharing tools sometimes wrap outbound links in ways that change how they're read.

What I'd tell someone starting from zero

If you've never touched HTML before, ignore anything that tells you backlinks need special formatting, schema markup, or hidden attributes to "count." They don't. A backlink counts because a real page, ideally one with its own traffic and trust, points a plain anchor tag at your URL, inside content that gives someone a reason to click it. Everything past that is either a rel attribute for legal and disclosure reasons, or a placement decision about where in the article the link sits. Spend your time getting invited onto better sites and writing sentences worth linking from, not memorising HTML attributes that don't move rankings on their own.

The free tool that counts a site's referring domains does the working out for you.

Not sure what a good one looks like? See what backlinks look like with real examples.

For hands-on help, my page on SEO for Google and AI search explains how I work.

Frequently asked questions

Do I need to use rel="dofollow" to make a backlink count?

No, that attribute doesn't exist in any meaningful sense to search engines. A plain anchor tag with no rel attribute is treated as a normal, fully credited link by default.

What's the difference between nofollow and sponsored in HTML?

rel="nofollow" is the general instruction not to pass ranking credit, while specifically flags a link as paid or an affiliate placement, which Google introduced in 2019 to separate paid links from other types of nofollow use like comments.

Can a backlink hurt my SEO if the HTML is wrong?

The HTML itself rarely causes harm unless it's broken badly enough that the link doesn't resolve at all, but a technically perfect link placed on a low quality or spammy page can still fail to help, and in extreme cases a pattern of manipulative anchor text across many links can trigger a manual penalty.

How do I check if my backlink is indexed?

View the page's HTML source to confirm the href is really there, then search site:yourpageurl.com in Google after a few days, or use the URL Inspection tool in Search Console if it's a page you control, to confirm the link has been crawled and counted.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.