Inline SVG vs <img> vs CSS Background: Choosing the Right One
The same optimized SVG file can end up on a page three genuinely different ways — pasted directly into the HTML, referenced through an <img> tag, or set as a CSS background-image — and which one is right depends on what you actually need to do with it afterward, not on which is "best" in the abstract.
Inline SVG: full styling and scripting access
Pasting the SVG markup directly into the HTML puts every element inside it in the DOM, reachable by CSS and JavaScript exactly like any other element on the page. This is the only option that lets you recolor parts of the icon with CSS (fill: currentColor to match surrounding text color, for instance), animate individual paths, or change parts of it dynamically in response to user interaction. The cost is that the browser can't cache it separately the way it caches an external file — an inline SVG's bytes are part of the page's own HTML, downloaded fresh with every page load, and repeating the same inline SVG on multiple pages means paying that cost repeatedly rather than once.
<img>: cacheable, simple, but style-locked
Referencing an SVG through <img src="icon.svg"> treats it exactly like any other image format — the browser fetches it once and caches it under its URL, reusing that cached copy across every page that references the same file. The tradeoff: CSS on the page can't reach inside it to change colors or otherwise restyle its internals, since from the browser's perspective it's an opaque image, not part of the page's own DOM. Whatever colors and styles are baked into the SVG file itself are what renders, full stop.
CSS background-image: for decoration, not content
Setting an SVG as a CSS background (background-image: url(icon.svg)) behaves similarly to <img> in terms of caching and styling limitations, but carries an important semantic difference: a CSS background isn't part of the accessible content of the page at all — screen readers don't announce it, and it doesn't appear in the page's content if CSS fails to load for any reason. This makes it the right choice specifically for decorative visuals that add nothing informational (a subtle background pattern, a purely aesthetic flourish) and the wrong choice for anything a user actually needs to perceive to understand the page, like a meaningful icon or a logo.
A quick way to decide
Need to recolor the icon with CSS, animate it, or change it with JavaScript? Inline it. Is it a static icon or logo appearing identically across many pages, where caching matters more than styling flexibility? Use <img>. Is it purely decorative with no informational content of its own? CSS background is fine, and appropriate specifically because it's excluded from the accessibility tree. Most icon systems in practice end up using a mix — commonly-repeated static icons as <img> or a sprite sheet, one-off icons that need dynamic color or interaction inlined directly.
Optimize before you decide
Whichever method you use, an unoptimized SVG carries the same editor bloat regardless of how it's embedded — inlining a bloated SVG just moves that bloat into the page's own HTML instead of a separate cacheable file. FreeToolDev's bulk SVG optimizer strips that overhead from a whole batch of icons at once before you decide how each one gets used.