New: SerpPal for Chrome. Free grammar checks on every site, and the AI humanizer right where you write.

Get it free

Example of Internal and External Linking in HTML: Links Explained

Copy-ready examples of internal and external linking in HTML, the rel and target attributes that matter, why the link tag is not a hyperlink, and SEO effects.

By SerpPal Team10 min read
HTML anchor tag examples showing an internal link and an external link side by side
On this page

Here's the simplest example of internal and external linking in HTML, the two types of links every webpage uses: <a href="/about/">About us</a> is an internal link, because it points to a page on the same website, and <a href="https://developer.mozilla.org/">MDN Web Docs</a> is an external link, because it points to a different domain. Both use the same anchor element and the same href attribute; the destination is the only difference. This guide gives you copy-ready snippets of each link type, explains the attributes that matter (target, rel, fragment identifiers), shows why the <link> tag for CSS is not a hyperlink, and covers what internal and external links each do for SEO and site structure.

Key takeaways

  • Internal links point to your own website (relative or absolute URL); external links point to another site.
  • Both are made with <a href="...">anchor text</a>. The <link> element loads resources such as CSS and is not a clickable link.
  • External links that open in a new window need rel="noopener"; paid or untrusted external links need rel="sponsored", rel="ugc" or rel="nofollow".
  • For SEO, internal links distribute authority (link juice) and help web crawlers find pages; external links add credibility and context but pass authority away from your website.
  • Descriptive anchor text helps people, screen readers and search engines alike. "Click here" helps nobody.

A hyperlink in HTML is an anchor element: an opening <a> tag with an href attribute that specifies the destination, the visible anchor text, and a closing </a>. That's the whole syntax. The browser renders the text as clickable and, on click, requests the URL in href. Everything else (new tabs, nofollow, jumping to a section) is added with attributes or by changing what the href points to.

text
<a href="https://www.yoursite.com/pricing/">See pricing</a>

Whether a link is internal or external has nothing to do with how it looks and everything to do with where the href goes. Same site: internal. Different site: external. A subdomain (blog.yoursite.com from www.yoursite.com) is usually treated as internal for SEO purposes, but technically it's a different host.

1. Relative path to another webpage on your website

text
<a href="/services/">Explore our services</a>

A root-relative path starts with a slash and is resolved against the current domain. It's the most maintainable form for internal links: if the site moves from staging to production, or from http to https, the link still works.

2. Absolute URL on your own domain

text
<a href="https://www.yoursite.com/contact/">Contact our team</a>

Still an internal link, because the domain is yours. Absolute URLs are useful in email templates and RSS feeds where relative paths would break, but inside your own pages the relative form is easier to keep correct.

text
<a href="#pricing">Jump to pricing</a>
...
<h2 id="pricing">Pricing</h2>

A fragment identifier (the part after #) scrolls to the element with the matching id. IDs must be unique on the page. You can combine a path and a fragment to deep-link into another page: href="/guide/#step-3". These are sometimes called anchor links or jump links; they help people reach different sections of a long page, and Google can show them as sitelinks in the SERPs.

text
<p>Before you add links, plan the structure with a
<a href="/docs/projects-and-teams/sitemap-and-internal-links">sitemap and internal links</a> guide.</p>

Contextual links sit inside relevant sentences rather than in a header, menu or footer. They carry the most meaning for people and for search engines, because the surrounding content gives the link contextual relevance: the sentence explains how the two web pages relate. That's the kind of internal link SerpPal suggests while you write: it reads your sitemap and offers existing pages to link where the sentence fits; see sitemap and internal links.

text
<nav aria-label="Breadcrumb">
  <a href="/">Home</a> &rsaquo;
  <a href="/blog/">Blog</a> &rsaquo;
  <span>Internal vs external links</span>
</nav>

Navigational links (header menus, breadcrumbs, footers, category taxonomies) are internal links that appear on every page. They define the site structure crawlers see and help users navigate, but because they're repeated sitewide, each one carries less weight than a contextual link.

The SerpPal editor, where internal link suggestions from the site's sitemap appear beside the text while writing
The SerpPal editor, where internal link suggestions from the site's sitemap appear beside the text while writing
text
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">The anchor element on MDN</a>

Use the full URL including https://. The anchor text should say what the reader will find, not where it is. External links cite sources, credit tools and point to further reading, and irrelevant ones only send people away.

text
<a href="https://othersite.org/report.pdf" target="_blank" rel="noopener">Download the report (PDF)</a>

target="_blank" opens the destination in a new window or tab. Always pair it with rel="noopener" (modern browsers imply it, but be explicit): without it, the new page gets a reference to your page's DOM through window.opener and can redirect it. Use this sparingly; people expect links to behave like links, and the back button is the usual way home.

text
<a href="https://partner.othersite.org/offer" rel="sponsored">Partner offer</a>
<a href="https://forum.othersite.org/thread/123" rel="ugc">Forum discussion</a>
<a href="https://unknown.othersite.org/" rel="nofollow">Unverified source</a>

The rel attribute specifies how search engines should treat the link. sponsored marks paid links and affiliate links, ugc marks user-generated content such as comments, and the nofollow attribute is the general hint not to pass ranking credit. Google treats all three as hints. Don't add nofollow to every external link by default; linking to good sources is normal and Google's own documentation on qualifying outbound links explains when each value applies.

text
<link rel="stylesheet" href="/css/site.css">
<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="preload" href="/fonts/inter.woff2" as="font" crossorigin>

The <link> element goes in the document <head> and tells the browser to fetch a resource: the first line loads and applies a stylesheet. It also uses href, which is why it's confused with hyperlinks, but it renders nothing in the page and can't be clicked. Other common uses are rel="icon" for providing icons in different sizes and usage contexts (favicon, Apple touch icon), rel="canonical" for the preferred URL of a page, rel="preload" with the crossorigin attribute for fonts (fonts are fetched as cross-origin requests even from your own domain), and rel="alternate stylesheet" or rel="alternate" for optional themes, feeds and translated versions. When you need to load a resource, use <link> (or <script src> for JavaScript); when you need a user to go somewhere, use <a>.

Browser developer tools Network panel showing site.css fetched as a stylesheet by a link element, next to the line of HTML that requested it
Browser developer tools Network panel showing site.css fetched as a stylesheet by a link element, next to the line of HTML that requested it
Internal linkExternal link
DestinationA page on the same domainA page on another domain
Typical href/blog/ or https://www.yoursite.com/blog/https://othersite.com/page/
Main purposeNavigation, related content, topic clusters, passing authorityCiting sources, crediting tools, further reading
SEO valueDistributes link equity inside your website; faster crawling and indexingSignals credibility and context; passes authority to the other website
Usual attributesNone neededrel="noopener" with new tabs; sponsored, ugc or nofollow where relevant
Who controls the destinationYouSomeone else; check it periodically for link rot

Internal links help search engines in three ways. Faster crawling and indexing: crawlers discover web pages by following links, so a page with no internal links (an orphan page) may never be crawled or indexed, while a well-linked page is found within days. Authority: a page with many backlinks can share its PageRank with the pages it links to, which is how a strong guide lifts a new blog post or a landing page; PageRank still flows along links, internal ones included. Relevance: anchor text tells Googlebot what the target page is about, which supports visibility in search results for the query you want it to rank for, and a linked page inherits some of the topical context of the page linking to it. In practice, internal linking is the most controllable part of an on-page SEO strategy, because every link is yours to add, and link building from other sites is not. Search engines can only rank content they've found, so guiding the crawl to your important pages is the first job of any link. Our guide to internal linking tools and strategies covers the audit side; the HTML side is simply the anchor element used well.

Search Console URL inspection for a blog post, showing the sitemap and the internal referring pages through which Google found it
Search Console URL inspection for a blog post, showing the sitemap and the internal referring pages through which Google found it

Internal linking best practices

  • Link new pages from older, relevant pages that already rank, not just the other way round.
  • Use descriptive, varied anchor text; avoid the same exact-match keyword on every link.
  • Keep important pages within three clicks of the homepage, and link each pillar page to the posts in its topic cluster.
  • Fix broken links and links to redirected URLs; both waste crawl budget.
  • Don't add nofollow to internal links. It blocks the authority you're trying to pass.
  • Prefer contextual links in body content over footer link lists for anything you want to rank.
  • Audit your internal links regularly: a quarterly crawl catches orphan pages, broken links and important pages that have drifted too deep.

Linking out to authoritative sources doesn't directly raise your rankings, but it makes a page more useful and more credible, which is what Google's quality guidance rewards. External links also pass authority to the destination, which is why paid placements must be marked sponsored. The external links that matter most for your SEO are the ones pointing to you from other sites, known as backlinks or inbound links; those are earned, not written. You can see which sites link to you in Search Console, as our guide to checking backlinks in Google Search Console shows. Keep your own outbound links relevant, limit them to sources that add something, and check them a couple of times a year, because external pages move and die.

Anchor text and accessibility

Screen readers often present a list of all links on a page, out of context. "Read more" five times tells the listener nothing; "read the pricing comparison" does. The same descriptive anchor text helps sighted visitors scanning the page, adds clarity about where links lead, and helps search engines classify the destination. Keep anchors short enough to scan, make the link visually distinct from body text (underline or clear colour contrast), and never use an image as the only link without alt text describing the destination.

A screen reader's links list with vague anchors such as Read more next to the same links with descriptive anchor text
A screen reader's links list with vague anchors such as Read more next to the same links with descriptive anchor text

Common HTML linking mistakes

  • Forgetting the protocol on an external link: href="othersite.org" is treated as a relative path to /othersite.org on your own site.
  • Using target="_blank" without rel="noopener".
  • Mixing up <link> and <a>.
  • Anchor links whose fragment doesn't match any id on the page, so the click does nothing.
  • Empty or JavaScript-only hrefs (href="#", href="javascript:void(0)") used as buttons. Use a <button> for actions and a link for navigation.
  • Keyword stuffing in anchors repeated excessively across the site, which reads as manipulation to people and can affect rankings negatively.
  • Never testing. Open each important link after publishing and after any URL change.

You don't need special software for a single page. Open the page, right-click and choose View Page Source, then search for <a to see every hyperlink and its attributes. Browser developer tools show the same and let you click straight to the element. For a whole site, a crawler lists every internal and external link, its status code and its anchor text, so broken links and redirect chains stand out. Google's link best practices are a good checklist: a real <a> element, an href that resolves to a URL, and anchor text that makes sense on its own. Links that only work through JavaScript click handlers may not be followed at all.

A crawler's report of every link on a page with anchor text, href, internal or external type, rel value and status code, including a broken link missing its protocol
A crawler's report of every link on a page with anchor text, href, internal or external type, rel value and status code, including a broken link missing its protocol

Conclusion

Internal and external links use exactly the same HTML: an <a> element, an href and clear anchor text. The destination is the only difference, and it decides what the link does for you. Internal links build your site structure and move authority to the pages you want to rank; external links cite sources and help readers, with rel values marking anything paid or untrusted. Keep the <link> tag for resources, test your links after every change, and they'll keep working for people and for search engines. For more on planning links at scale, see the on-page SEO checklist.

FAQs

Use an anchor element with an href that points to a page on your own site, for example <a href="/about/">About us</a>. The href can be a relative path or an absolute URL on your domain.

An anchor element whose href points to a different domain, such as <a href="https://developer.mozilla.org/">MDN</a>. Add rel="noopener" if it opens in a new window and rel="sponsored" if it's paid.

What is the difference between internal and external linking?

Internal linking connects pages on the same website and shapes how authority and crawlers move through your site. External linking points visitors to other websites, usually to cite a source or recommend a resource. The HTML is identical; only the destination domain differs.

Put <link rel="stylesheet" href="/css/site.css"> inside the document's <head>. This loads the stylesheet; it isn't a clickable hyperlink.

No, relevant external links to good sources don't hurt and can make a page more useful. Paid or untrusted links should carry rel="sponsored" or rel="nofollow", and broken outbound links should be fixed, but linking out is normal.

Write your next post with a live score.

SerpPal reads the pages that rank for your keyword and scores your draft as you write. Free plan, no card needed.