Skip to content

Allow omission of fragment when using SVG <use> #1045

Closed

Description

@o-t-w

Description

Currently developers need to manually edit each SVG file to include an id on the <svg> element, which is labourious:

<svg id="icon" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
    <circle cx="5" cy="5" r="5"/>
</svg>

And then reference that id:

<svg>
    <use href="homeicon.svg#icon"></use>
</svg>

SVG 2 allows <use> to reference entire files by omitting the fragment. Unfortunately this is only implemented in Chrome/Edge.

Explainer

In the age of HTTP/2/HTTP/3, there is no performance reason to bundle SVG assets together. By storing each icon as an individual file (rather than a spritesheet where multiple icons are stored together in a single file), it remains easy to also use the icons as a CSS background-image or as the src of a HTML <img> tag, and you can easily open them in design software, so this use-case should be made more ergonomic.

Specification

https://svgwg.org/svg2-draft/linking.html#SVGFragmentIdentifiers

web-feature

No response

Test Links

No response

Additional Signals

Mozilla standard position: neutral

WebKit standard position

Activity

  1. added
    focus-area-proposal
    on Sep 6, 2025
  2. changed the title [-]Allow omission of fragment when using SVG <use>[/-] [+]Allow omission of fragment when using SVG `<use>`[/+] on Sep 6, 2025
  3. github-actions commented on Sep 6, 2025

    @github-actions

    This comment was automatically generated based on the information you provided. Please don't edit it.

    No web features (from the web-features project) were found in your proposal. If your proposal doesn't correspond to a web feature, that is fine.
    Otherwise, please update your initial comment to include web-features: <feature-id>.
    To find feature IDs, use the web-features explorer.

  4. kanashimia commented on Sep 7, 2025

    @kanashimia

    Some remarks:

    In the age of HTTP/2/HTTP/3, there is no performance reason to bundle SVG assets together.

    Bundling still provides benefit, for example if you have a lot of small icons which are all used bundling them could decrease data being sent by quite a bit because they are all compressed together.
    It is something that is pretty tedious to do and manage though as you don't want to send unused icons too.

    Also worth noting that such spritesheet generation could be automated, for example using something like this:
    https://github.com/SpiriitLabs/vite-plugin-svg-spritemap or https://github.com/cascornelissen/svg-spritemap-webpack-plugin
    Same for just adding an id without generating a spritesheet, but in that case it is really just an extra work to create a workaround.

  5. dholbert commented on Nov 24, 2025

    @dholbert

    Are there WPTs for this?

  6. dholbert commented on Jan 13, 2026

    @dholbert

    Are there WPTs for this?

    Answering myself to some extent... There is at least one WPT for this, mentioned in the Chromium bug that added support:
    wpt.fyi: https://wpt.fyi/results/svg/struct/reftests/use-external-svg-resource-no-fragment-id.html
    wpt.live: https://wpt.live/svg/struct/reftests/use-external-svg-resource-no-fragment-id.html

    It has:

    <use href="support/sprites-without-id.svg"></use>

    which is directly testing this behavior.

  7. gsnedders commented on Jan 21, 2026

    @gsnedders
    Member
    web-platform-tests % rg --multiline '<([^:]+:)?use\s[^>]*href[^#>]*>'
    resource-timing/initiator-type/svg.html
    20:    <use href="/resource-timing/resources/dummy.svg"></use>
    
    svg/interact/script-common.html
    34:  <use href="spot">
    
    svg/struct/reftests/use-external-svg-resource-no-fragment-id.html
    6:  <use href="support/sprites-without-id.svg"/>
    

    Though only the last of these looks deliberate.

  8. wpt-interop commented on Feb 12, 2026

    @wpt-interop
    Collaborator

    Thank you for proposing Allow omission of fragment when using SVG <use> for Interop 2026.

    We want to let you know it was not selected to be part of Interop this year.

    On behalf of the entire Interop team, thank you for submitting it for consideration. We got many more proposals than we could include in this year's project, necessitating some difficult choices. Please note this should not be taken as a comment on the technology as a whole, or our willingness to consider it for Interop in the future. We appreciate the work you put into your proposal, and would welcome your participation in future rounds of Interop.

    Posted on behalf of the Interop team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus-area-proposal

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions