DEV Community

Ingo
Ingo

Posted on

SVG image tag generator / feedback

Hi

While building a website with AI assistance, I came across an SVG technique that was new to me: Multiple images are stored in a single SVG file but can still be embedded individually using a standard tag—for example, with sprite.svg#icon.

For my project, I found this method easier to implement and maintain than traditional CSS background sprites because there's no need to manage image positions using background-position. This led to the idea of developing a web generator that simplifies this workflow:

Try the SVG Sprite Generator: https://css-img-sprite-generator.ingozoell.de/en/

The generator combines images into a single SVG file and provides the appropriate HTML and CSS code for individual embedding. My goal is to make an existing technique easier to use.

If you have the time and are interested, I'd love for you to try out the generator. I'm particularly interested in your feedback and any limitations or issues you might notice.

Thank you very much for your time and your helpful contributions.

Best regards,
Ingo from Germany

Top comments (3)

Collapse
 
svgicons profile image
Svg/icons •

One limitation worth documenting: SVG fragments loaded through stay in a separate document, so currentColor and host-page CSS won’t cascade into them. Have you considered that?

Collapse
 
ingozoell profile image
Ingo •

Thanks for pointing that out — it's a limitation worth documenting. With the <img src="sprite.svg#…"> approach, the SVG is rendered as a separate image document. Host-page CSS and currentColor don't cascade into its internal shapes.

That makes this approach better suited to graphics with predefined colors. For icons that need to inherit text colors or respond to CSS theming, inline SVG or CSS masks are a better fit.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.