SVG Links
You are Here:
How to Create a Link?
The <a>
SVG element creates a hyperlink to other web pages, files, locations in the same page, email addresses, or any other URL. It is very similar to HTML's <a> element.
In this example. we will create a link for SVG text by using <a>
SVG element.
Example
HTML Online Editor
<!DOCTYPE html>
<html lang="en-US">
<body>
<svg height="20" width="80" xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="/svg" target="_blank">
<text x="0" y="15" fill="red">Learn SVG!</text>
</a>
</svg>
</body>
</html>
Link for SVG Circle
As same as above example. This example will create a link for SVG circle by using <a>
SVG element.
Example
HTML Online Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
svg circle{
stroke:red;
stroke-width:3;
fill:green;
}
</style>
</head>
<body>
<svg height="100" width="100" xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="/svg" target="_blank">
<circle cx="50" cy="50" r="40" />
</a>
</svg>
</body>
</html>
Attributes Value
Attribute | Explanation |
---|---|
xmlns:xlink | Specifies the xml namespace for a document. |
xlink:href | Specifies the location of the referenced object. |
target | Specifies where to open a document. |
Reminder
Hi Developers, we almost covered 91% of SVG Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in SVG.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.