Tutorials About

1 SVG Tutorial
2 SVG Examples
3 A Simple SVG Example
4 Displaying SVG in Web Browsers
5 SVG Coordinate System
6 SVG svg element
7 SVG g element
8 SVG rect element
9 SVG circle element
10 SVG ellipse element
11 SVG line element
12 SVG polyline element
13 SVG polygon element
14 SVG path element
15 SVG marker element
16 SVG text element
17 SVG tspan element
18 SVG tref element
19 SVG textpath element
20 SVG switch element
21 SVG image element
22 SVG a element
23 SVG defs Elements
24 SVG symbol Element
25 SVG use Element
26 SVG and CSS - Cascading Style Sheets
27 SVG Stroke
28 SVG Fill
29 SVG Viewport and View Box
30 SVG Animation
31 SVG Scripting
32 SVG Transformation
33 SVG Gradients
34 SVG Fill Patterns
35 SVG Clip Path
36 SVG Masks
37 SVG Filters

SVG a element

The SVG <a> element is used to create links in SVG images. SVG links work just like HTML links. Here are a few simple examples:

<svg xmlns=""

    <a xlink:href="/svg/index.html">
        <text x="10" y="20">/svg/index.html</text>

    <a xlink:href="/svg/index.html" xlink:show="new">
        <text x="10" y="40">/svg/index.html

    <a xlink:href="/svg/index.html" xlink:show="replace">
        <text x="10" y="60">/svg/index.html

    <a xlink:href="/svg/index.html" target="_blank">
        <text x="10" y="80">m/svg/index.html

    <a xlink:href="/svg/index.html" target="_top">
        <text x="10" y="100">/svg/index.html


Here is the resulting image:

You can set the xlink:show attribute on the <a>-element to either new or replace, to tell whether the content the link points to should be displayed in a new window, or replace the content of the existing window.

Note, that if you use replace and you display the SVG image inside an iframe, the iframe will be the target of the link and not the browser window. If you want the browser window to be the target instead of the iframe, use the target attribute with a value of _top instead.

You can also set the target attribute to tell the browser to open the link in a specific frame or specific window. This works just like the target attribute of links in HTML (at least in theory). Be aware that the browsers interprets the value of the target attribute in different ways. See the last section on this page for more detail.

Shapes as Links

It is also possible to use shapes as links. All you need to do is to put the SVG shape you want to use as link between the <a> and </a> tags. Here is an example that uses a rectangle as link instead of a text:

<svg xmlns=""

    <a xlink:href="/svg/index.html" target="_top">
        <rect x="10" y="20" width="75" height="30"
                style="stroke: #333366; fill: #6666cc"/>

And here is the resulting image:

Connect with me: Newsletter - Get all my free tips!

This website uses cookies to improve the user experience and gather statistics. Our advertisers use cookies too (3rd party cookies), to provide more relevant ads. Continued use of this website implies that you accept the use of cookies on this website. We do not share our cookies with our advertisers, and our advertisers do not share cookies with us.