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?
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.
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.
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.
Yes, xlink:href
will be dropped but for now I think the best long term option is to use both attributes together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With