Usage of IDs #6
DarkWiiPlayer
started this conversation in
General
Replies: 1 comment
-
Nice idea. I think we determine a namespace like `heh-icon-- or also to guarantee unique id's in our svg files. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I already commented this on #1, but there's the question of whether IDs should be used within SVG-files.
Advantages
IDs are the only way to use several features of SVG, such as
<use>
tags to repeat one element several times in a graphicsor use elements from other SVG elements on the document or even external SVG files
as well as linking to predefined views in an SVG document
Disadvantages
SVG-Files can easily be embedded into HTML pages by server-side tools, in which case special care has to be taken not to embed the same SVG-File twice should it have any IDs, as these are not allowed to appear repeatedly within one element (although most browsers will not care, HTML validators will complain and thus hurt SEO).
This could, of course, be mitigated by server-side tools that take care of not repeatedly embedding one SVG and instead only embed an empty SVG with a single
<use>
tag pointing to the first appearance. This can, however, lead to unexpected CSS interactions, as theuse
d element is now taken outside of its surrounding environment in the SVG, as well as potentially causing render bugs (one such bug in chrome has only recently been fixed, where the interaction of<use>
and CSS-@Keyframe animations was causing elements to sometimes appear with the wrong colour, presumably due to faulty caching logic).Beta Was this translation helpful? Give feedback.
All reactions