HTML SVG Links

Beginner
8 min read
Updated: Nov 2026
5 examples
Live preview

Definition and Usage

The SVG <a> element creates a hyperlink, much like the HTML <a>. It is a container: wrap text, a circle, a rect, or a group.

Set modern href to a page, file, email, or fragment. For toggles and non-navigation actions, prefer SVG interactivity instead.

Baseline · Widely available.

SVG links with href are stable across modern browsers since about July 2015.

Deprecated for new work: xlink:href.

Prefer href. Keep xlink:href only when you must support very old SVG content.

No default link look.

SVG does not underline links for you. Add hover/focus styles (and a pointer cursor) yourself.

Syntax

link.html
<svg width="200" height="140" viewBox="0 0 200 140"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Linked circle example">
  <a href="https://example.com" aria-label="Example website">
    <circle cx="100" cy="70" r="45" fill="#2563eb" />
  </a>
</svg>

Pattern: wrap the graphic → set href → give an accessible name if needed.

Attributes

Common SVG link attributes:

AttributeDescriptionTry it
hrefDestination URL or fragmentTry it
targetWhere to open (_self, _blank, …)Try it
relLink relationship; use noopener with _blankTry it
downloadHint to download instead of navigateTry it
aria-labelAccessible name when the graphic has no textTry it
xlink:hrefLegacy URL attribute — avoid for new pagesTry it

Global Attributes

The SVG <a> tag also supports the Global Attributes in HTML (for example id, class, lang, title) when used in an HTML document.

Live Preview

Hover the linked circle. Click jumps to the Examples section on this page (href="#examples").

Fragment links stay on the page — good for demos.

SVG
Click → Examples

href="#examples" · hover to highlight

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Link Around a Shape

Wrap a circle with SVG <a href>.

HTML
<svg width="200" height="140" viewBox="0 0 200 140"
     xmlns="http://www.w3.org/2000/svg">
  <a href="https://example.com" aria-label="Example website">
    <circle cx="100" cy="70" r="45" fill="#2563eb" />
  </a>
</svg>
Try It Yourself

How It Works

  1. Open <a href="…"> inside the SVG.
  2. Put a painted shape inside the link.
  3. Add aria-label when there is no visible text.
  4. Close </a> after the shape.

Example 2 — Link Around Text

SVG text uses fill for color (not CSS color alone).

HTML
<svg width="240" height="80" viewBox="0 0 240 80"
     xmlns="http://www.w3.org/2000/svg">
  <a href="https://example.com">
    <text x="120" y="48" text-anchor="middle"
          fill="#2563eb" font-family="system-ui,sans-serif"
          font-size="22" text-decoration="underline">
      Visit example.com
    </text>
  </a>
</svg>
Try It Yourself

How It Works

  1. Wrap <text> in SVG <a>.
  2. Style with fill for the text color.
  3. Add underline if you want a classic link look.
  4. Visible text often removes the need for aria-label.

Example 3 — Open in a New Tab

Use target="_blank" with a safe rel.

HTML
<svg width="220" height="120" viewBox="0 0 220 120"
     xmlns="http://www.w3.org/2000/svg">
  <a href="https://example.com"
     target="_blank" rel="noopener noreferrer"
     aria-label="Example.com (opens in a new tab)">
    <rect x="30" y="30" width="160" height="60" rx="10" fill="#16a34a" />
    <text x="110" y="66" text-anchor="middle" fill="#fff"
          font-family="system-ui,sans-serif" font-size="16"
          pointer-events="none">New tab</text>
  </a>
</svg>
Try It Yourself

How It Works

  1. target="_blank" opens a new browsing context.
  2. rel="noopener noreferrer" is the safe habit with _blank.
  3. Mention new tab in the accessible name when helpful.
  4. pointer-events="none" on text keeps hits on the rect.

Example 4 — Multiple Linked Shapes

Each shape can have its own destination.

HTML
<svg width="280" height="120" viewBox="0 0 280 120"
     xmlns="http://www.w3.org/2000/svg">
  <a href="https://example.com" aria-label="Blue link">
    <circle cx="60" cy="60" r="35" fill="#2563eb" />
  </a>
  <a href="https://example.org" aria-label="Green link">
    <circle cx="140" cy="60" r="35" fill="#16a34a" />
  </a>
  <a href="https://example.net" aria-label="Orange link">
    <circle cx="220" cy="60" r="35" fill="#ea580c" />
  </a>
</svg>
Try It Yourself

How It Works

  1. One <a> per destination.
  2. Name each control with aria-label.
  3. Space the shapes so hit areas do not overlap.
  4. Reuse the same pattern for icons in a toolbar.

Example 5 — Hover Style

Add CSS so linked shapes look interactive.

HTML
<style>
  #badge { fill: #7c3aed; cursor: pointer; }
  a:hover #badge,
  a:focus-visible #badge {
    fill: #5b21b6;
    stroke: #0f172a;
    stroke-width: 3;
  }
</style>
<svg width="200" height="140" viewBox="0 0 200 140"
     xmlns="http://www.w3.org/2000/svg">
  <a href="https://example.com" aria-label="Purple badge link">
    <rect id="badge" x="40" y="35" width="120" height="70" rx="12" />
  </a>
</svg>
Try It Yourself

How It Works

  1. Give the shape an id for a CSS selector.
  2. Style a:hover #badge for pointer feedback.
  3. Add :focus-visible for keyboard users.
  4. Keep CSS minimal — only fill/stroke/cursor.

Edge Cases & Pitfalls

Most broken SVG links are hit areas, styles, or the wrong kind of <a>.

hit area

Unpainted shapes are hard to click

fill="none" with no stroke may ignore clicks. Give the link a painted region or adjust pointer-events.

css

Selector a matches HTML too

A bare a { } rule can style HTML links. Scope with svg a or an SVG @namespace when mixing both.

a11y

Name icon-only links

Shape-only links need aria-label (or visible text) so assistive tech can announce the destination.

action

Links navigate; scripts toggle

If the control does not go to a URL, use interactivity patterns instead of a fake href="#".

Browser Support

The SVG <a> element with modern href is supported in every modern browser.

✓ Baseline · Widely available

SVG <a>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support SVG links with href. Prefer href over xlink:href for new content.

97% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer 9+
Partial (xlink era)
SVG <a href> Widely supported

Bottom line: Safe for production icon navigation in modern browsers. Always style hover/focus and name graphic-only links.

Key Takeaways

  • Wrap shapes or text in SVG <a>.
  • Use href (not legacy xlink:href).
  • Style hover/focus yourself — no UA underline.
  • _blank: add rel="noopener noreferrer".

One line: SVG <a href> around a painted graphic.

Default CSS Settings

SVG links start visually plain. A small starter set:

defaults.css
/* Scope to SVG anchors when the page also has HTML links */
svg a {
  cursor: pointer;
}

svg a:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Text links: SVG uses fill, not color alone */
svg a text {
  fill: #2563eb;
  text-decoration: underline;
}

Prefer svg a (or an SVG @namespace) so HTML anchors are not restyled by accident.

Frequently Asked Questions

Wrap the shape in an SVG <a> and set href. Example: <a href="/page"><circle ... /></a>.
Prefer modern href. xlink:href is legacy. New content should not rely on xlink:href alone.
Use target="_blank" and rel="noopener noreferrer" so the new page cannot access window.opener.
Check overlays, pointer-events, and whether the shape has a painted hit area (fill or stroke).
SVG links have no default underline. Style the child shape, for example a:hover circle { fill: ... }.
Use SVG <a> for real navigation. Use scripts and roles for toggles and app actions — see SVG Interactivity.

Back to SVG Introduction

Review the SVG basics hub and pick your next shape or effect.

SVG Introduction →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful