Typography, Color Spaces & Vector Craft
Designing Crisp Technical SVG Diagrams with Consistent Stroke and Grid Rules
An SVG can look sharp in the drawing tool and still lose thin connectors, arrow direction, or small labels when it lands in a mobile article. This EMFLS Studio Journal field guide builds a 720-unit schematic you can check at 320 CSS pixels, with three measured stroke weights, repeatable arrowhead geometry, and at least 4.5:1 contrast for labels.
Set the viewBox before drawing the grid
Start with the narrowest space the finished figure will actually get. A 360 CSS pixel phone viewport with 20 pixels of article padding on each side leaves 320 pixels for the SVG. Use viewBox="0 0 720 320", give the figure the available width, and let its height follow the aspect ratio. At 320 pixels wide the figure is about 142.2 pixels high and one user unit occupies 0.444 CSS pixels. A 40-unit interval becomes 17.78 CSS pixels. SVG coordinate systems specification
Use the 40-unit grid for structure. In the figure, place the port at (80, 164) and the destination at (320, 164), six intervals away. Keep the working origin and grid phase in the drawing notes. Here the grid begins at (40, 84), so its horizontal rows fall at y = 84, 124, 164, and 204. The arrowhead and text baselines can sit between grid lines. Their coordinates come from the geometry and type sizes. Check the painted bounds at the perimeter, especially where round caps and thick outlines extend beyond their path coordinates.
If a fixed-height panel introduces spare space, inspect the actual fitted drawing. A 320 by 120 CSS pixel box with proportional fit limits this viewBox to a scale of 0.375, so the drawing is 270 pixels wide. Use that scale for every size check in the panel. The nominal 28-unit text would render at 10.5 CSS pixels there. Restoring the figure's natural height is the first fix to try when the layout permits it.
Give each stroke weight a job
Use 4 units for primary flow, 3 for secondary connections, and 2 for leaders and dimensions. Carry a second cue where a change in weight could be missed. A primary route can be the only continuous path with a filled arrowhead, while a leader ends at an annotation and approaches from a different direction. At phone size the primary and secondary widths differ by only 0.44 CSS pixels.
| Element | User units | CSS px at 720 wide | CSS px at 320 wide |
|---|---|---|---|
| Grid interval | 40 | 40 | 17.78 |
| Primary flow | 4 | 4 | 1.78 |
| Secondary connection | 3 | 3 | 1.33 |
| Dimension or leader | 2 | 2 | 0.89 |
| Arrowhead length | 32 | 32 | 14.22 |
| Smallest label font size | 28 | 28 | 12.44 |
Check how the edges land at your reference size. At 720 CSS pixels and device pixel ratio 1, with an integer-aligned SVG origin, a 4-unit horizontal stroke centered at y = 164 covers y = 162 through 166. A 3-unit stroke centered there has edges at 162.5 and 165.5. Moving its center to 164.5 puts the edges at 163 and 166. Use that adjustment on an isolated horizontal sample where the shift is harmless. At narrow widths or fractional zoom the same offsets land differently. Keep the grid and junctions steady and tolerate antialiasing where alignment would otherwise drift.
Where parallel connectors crowd together, measure the clear gap between their painted edges. Two 4-unit strokes with centerlines 8 units apart leave a 4-unit gap, about 1.78 CSS pixels on the phone. Move one route by a 20-unit half step if the gap closes visually around a bend. Check the new route from end to end for crossings.
Draw the arrowhead from its tip
Choose the destination point first. For the rightward arrow, put the tip at (320, 164). Move back 32 units to x = 288 for the base, then place its corners 16 units above and below the centerline. The included tip angle is twice the arctangent of 16 divided by 32, or about 53.1 degrees. Extend the 4-unit shaft to x = 292 so it overlaps the fill by 4 units. That overlap prevents a background-colored seam at the base. At 320 CSS pixels the head measures about 14.2 pixels along the axis and the same across the base.
For a diagonal connector, use the last segment to set the direction. From (200, 80) to (320, 170), the displacement is (120, 90), its length is 150, and the unit direction is (0.8, 0.6). Subtract 32 times that direction from the tip to get the base center (294.4, 150.8). Add and subtract 16 times the perpendicular vector (−0.6, 0.8) to get corners (284.8, 163.6) and (304, 138). Keep those decimals so both sides stay symmetric.
For a repeated SVG marker, put its reference point at the tip, use orient="auto", and select markerUnits="userSpaceOnUse" when heads should share a size across stroke weights. Move a bend upstream if the final straight segment is too short to contain the head. Then inspect the actual tip at the destination and zoom in on the base to check for a stray shaft end. SVG marker geometry
Measure labels against their immediate background
Set 4.5:1 as the minimum contrast for small labels and 12 CSS pixels as a studio minimum font size at the narrowest supported width. The 28-unit labels here compute to 12.44 CSS pixels at 320 wide. That value describes the font size, so check the lettering itself. In coordinate labels the differences between a zero and a capital O, or between a one and a lowercase l, can disappear before the rest of the word becomes hard to read. WCAG minimum text contrast
On the opaque #f8fafc canvas, #141923 measures 16.82:1 and #0f4c5c measures 9.09:1. The orange #b85c28 measures 4.36:1 on the same canvas, so it serves as the filled arrowhead. The pale #cbd5e1 grid measures 1.42:1 and serves as a drafting aid. The dark bracket and its label carry the measurement. Aim for at least 3:1 against adjacent colors where a graphic boundary is necessary to understand the diagram. Recalculate against the actual adjacent fill if an essential mark crosses a tinted panel. WCAG non-text contrast
Leave 12 user units around text where space allows, about 5.3 CSS pixels at the mobile width. Check the rendered bounds in the browser because a shared baseline says little about descenders or fallback font widths. Give a crowded label its own line or its own opaque backing and retest contrast against that backing.
Check the exported figure at its actual widths
Put the exported SVG in the article layout before signing off. At 320 CSS pixels and device pixel ratio 2, the 2-unit leader is about 1.78 device pixels wide before antialiasing. Its layout width is still about 0.89 CSS pixels. Compare that rendering with the same CSS width at ratio 1. If the leader disappears in one view, increase it to 3 units and recover the hierarchy through placement and endpoints. If several labels fall below the size floor at a narrower breakpoint, stack the legend under the drawing in a dedicated narrow layout and check the new viewBox against the same thresholds.
- Measure the rendered SVG box at 720 and 320 CSS pixels and at any narrower supported layout. Recalculate label and stroke sizes from the fitted drawing dimensions.
- Read the smallest label at normal zoom on both a standard and a high-density display. Check for collisions, clipped characters, and confused digits.
- Follow the flow from port to tip. Confirm that the arrowhead joins its shaft cleanly, its tip hits the intended point, and its direction is apparent without color.
- Check text contrast and essential line contrast against the actual adjacent fills. Verify that the SVG has an accessible name and that the caption explains the measured span.
- Record the tested width, pixel ratio, and zoom with the approved SVG so the next edit can reproduce the check.