On this page
A vector icon can look soft even when its geometry is perfectly valid. Thin strokes cross a raster grid when the browser paints them, and the result depends on scale, position, and display density. Sharpness comes from understanding that conversion, not from rounding every coordinate indiscriminately.
Start with the intended display size
Choose a reference size before adjusting coordinates. A drawing intended for 24 CSS pixels can behave differently at 20 or 18 pixels because the scale changes every stroke and gap. The SVG path scaler helps when creating a genuinely resized coordinate variant; it is not necessary merely to render an SVG at another CSS size.
Record the viewBox, default stroke width, and supported rendered sizes. Then choose a few diagnostic symbols: a horizontal line, a vertical line, a diagonal, a circle, and a dense settings shape. These expose different rasterization behaviors more clearly than a single favorite icon.
Do not judge crispness from an enlarged screenshot alone. Inspect at actual size first, then zoom in to understand the edge coverage. Enlarged pixels can make a good icon look alarming even when the normal-size result is balanced and legible.
Remember that strokes straddle their paths
A stroke centerline lies halfway through the painted width. At a one-to-one mapping between SVG units and CSS pixels, a one-unit vertical stroke centered on a whole coordinate extends half a unit to either side. Placing that centerline on a half coordinate may align its outside edges with pixel boundaries.
A two-unit stroke behaves differently: its outside edges can align when its centerline uses a whole coordinate. These examples explain the familiar half-pixel advice, but only under the assumed mapping and position.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
width="24" height="24" fill="none" stroke="currentColor">
<path d="M4.5 4v16" stroke-width="1" />
<path d="M10 4v16" stroke-width="2" />
</svg>Consult the MDN stroke-width reference for the underlying property. Applying the same coordinate adjustment to every stroke width is not a consistent sharpness strategy. It can improve one family member while making another softer or shifting its apparent alignment.
Account for transforms and display density
The browser eventually maps the icon onto device pixels. CSS pixels are not necessarily device pixels, and layout can place an element at a fractional position. A carefully aligned path may still land between device pixels after scaling or translation.
For example, shrinking a 24-unit icon to 18 CSS pixels applies a factor of 0.75. A two-unit stroke becomes 1.5 CSS pixels before device-density mapping. That is not a rendering bug; it is the expected geometry.
Inspect parent transforms and fractional dimensions before rewriting the asset. A scaled container or centered layout can change the final placement. The MDN devicePixelRatio documentation explains the relationship between CSS and device pixels, but the application should not ordinarily compensate by generating bespoke path geometry for every possible ratio.
Prefer a small set of intentional icon sizes. If an important compact size consistently loses clarity, produce a simplified variant for that size instead of trying to force one drawing onto every raster grid. Uniform family behavior matters more than perfect edge alignment in one screenshot.
Use non-scaling strokes only when appropriate
The non-scaling-stroke vector effect keeps stroke thickness from scaling with the geometry in the usual way. It can be useful for diagrams or symbols whose outlines should remain visually constant during zooming, but it changes the relationship between outline thickness and internal detail.
<path d="M4 12h16" stroke="currentColor" stroke-width="2"
vector-effect="non-scaling-stroke" />The MDN vector-effect reference describes this behavior. Test the smallest and largest instances before applying it to a family. At small sizes, a constant-width outline can swallow internal spaces that would otherwise shrink proportionally.
Do not add the effect as a generic cure for blur. It does not align arbitrary geometry to a pixel grid, and it may make a large icon look unexpectedly delicate. Choose it because the design requires constant visual stroke width, not because a preview looked soft once.
Use the image dimension calculator when comparing raster proof exports. Label each export with its intended CSS size and density so reviewers do not compare a one-density screenshot with a double-density asset at inconsistent zoom levels.
Review sharpness as part of family quality
Create a rendering fixture with the supported sizes, several display backgrounds, and the actual controls that use the icons. Include both centered standalone symbols and symbols next to text. Check the fixture without browser zoom before testing enlarged views.
Keep this review order:
- Confirm the symbol is recognizable at its smallest intended size.
- Check gaps, enclosed counters, and neighboring stroke collisions.
- Inspect whether horizontal and vertical strokes feel equally weighted.
- Compare diagonals and circles without expecting staircase-free edges.
- Identify layout transforms before editing source coordinates.
Browse the icons and illustration guides for related grid and drawing decisions. Sharp edges cannot rescue a symbol with excessive detail or poor optical balance, so solve those issues first.
Document any size-specific corrections with the rendered context that justified them. A half-unit adjustment without an explanation can be reversed during the next cleanup pass. A comparison showing that it preserves an open gap at 16 pixels gives the next contributor a concrete reason to keep it.
Work through a compact-size correction
Suppose a 24-unit settings icon uses two-unit strokes and contains a two-unit gap between neighboring outlines. At 16 CSS pixels, both the stroke and the gap become approximately 1.33 CSS pixels. Depending on position and density, partially covered edge pixels may make that gap appear narrower than the nominal geometry suggests.
First render the icon without parent transforms at 16, 20, and 24 pixels. If the compact version alone becomes muddy, test a simplified compact drawing: remove a minor interior detail or widen the crowded gap while preserving the outer silhouette. Compare it beside other icons at the same size rather than approving it in isolation.
Avoid rounding every coordinate after scaling. Rounding can change symmetry, curve tangency, and spacing by different amounts across the drawing. Preserve the original as the reference asset, and name the compact variant by its supported use rather than calling it a universally sharper replacement. Store a small before-and-after proof with the source so future optimization does not erase the optical correction. Recheck the variant on both ordinary-density and high-density displays before accepting it.
Key takeaways
- Judge sharpness at the intended size before inspecting enlarged pixels.
- Stroke width and centerline placement must be considered together.
- Scaling, layout position, and device density affect the final rasterization.
- Non-scaling strokes preserve thickness, not automatic pixel alignment.
- Prefer intentional size variants over universal coordinate-rounding rules.
Reach designers & developers at work
Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.
Become a sponsor