My SVG icons look blurry on retina, what am I doing wrong?

wafflesRgood

New Member
Messages
57
Reaction score
0
Location
Berlin, DE

So I'm building a little website to log my water parameters because I'm super paranoid about my fish dying (already lost one neon tetra last month, still not over it). I made these SVG icons for the nav and they look fine on my old MacBook but on my iPhone they're all fuzzy around the edges. I set width="24" height="24" and viewBox="0 0 24 24" so I thought that was enough? Do I need to do something with the actual paths or is it a CSS thing? I tried adding shape-rendering="crispEdges" but that just made them look pixelated. I'm worried I'm messing up something basic. Also does it matter if I use <img> vs inline SVG? I'm using <img> right now. Any tips would be great, I just want my fish log to look nice.

tallguy_tx

New Member
Messages
61
Reaction score
0
Location
Austin, TX

Been down this exact rabbit hole. Rebuilt a landing page for a bookie mirror last year and the mobile icons looked like trash for a solid week before I figured it out.

Fuzzy on iPhone almost always means something in the SVG is getting rasterized at 1x and then scaled up. First, open the file in a text editor and look for &lt;image&gt; tags or any filters. Embedded bitmaps and blur filters are the usual suspects. Second, check your CSS isn't slapping a fixed px size on top of the width/height attributes. That fights the viewBox and Safari handles it way worse than Chrome does.

shape-rendering="crispEdges" is the wrong tool here. It snaps everything to the pixel grid, which is exactly why you got that crunchy look. Drop it.

&lt;img&gt; vs inline won't cause the fuzz either way. &lt;img&gt; is fine for static icons and it caches better. Inline only really matters if you want to recolor them with currentColor.

But my actual bet is your paths have strokes sitting on fractional coordinates. A 1.5 stroke at x=10.25 looks soft on every device. Snap your coords to whole numbers or .5 at most and it'll clean right up.

You must log in or register to reply here.