Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is xlink:href deprecated for svg <image>s?

Tags:

javascript

svg

According to MDN xlink:href, we should use href instead of xlink:href, but on the svg example page (which was last updated July 6, 2017), the attribute in the example is xlink:href.

Does it matter which attribute is used?

like image 923
asparism Avatar asked Jul 18 '17 04:07

asparism


People also ask

How do I add a link in SVG?

The simplest way to make a portion of an SVG clickable is to add an SVG hyperlink element to the markup. This is as easy as wrapping the target with an <a> tag, just as you would a nested html element. Your <a> tag can surround a simple shape or more complex paths. It can surround a group of SVG elements or just one.

What is xmlns XLink?

XLink is used to create hyperlinks in XML documents. XLink is used to create hyperlinks within XML documents. Any element in an XML document can behave as a link. With XLink, the links can be defined outside the linked files. XLink is a W3C Recommendation.


2 Answers

The upcoming SVG 2 standard is dropping the requirement for the xlink: prefix. Some browsers support that option, but not all do. The safe (and backward compatible) option for now is to keep using it.

like image 102
Paul LeBeau Avatar answered Oct 04 '22 17:10

Paul LeBeau


Yes, xlink:href will be dropped but for now I think the best long term option is to use both attributes together.

like image 40
Gesha Avatar answered Oct 04 '22 17:10

Gesha