Menu

1 / 2

Why Do SVG Dashes Shift When You Split a Path?

DEV Community: css·Axialis Software·9 days ago
#W59UbMNL
#devtocss#devto#dev#dash#offset
Long article (753 words) — no AI summary yet.
Reading 0:00
15s threshold

You cut a dashed SVG outline into two pieces so you can style them separately. The pieces still meet at exactly the same point, but the dash over the cut gets longer. The next dash moves too.

A dashed stroke starts its pattern at the beginning of each subpath. Splitting a path adds a new starting point, so the second piece needs its own dash offset to pick up where the first piece left off.

One line, three renderings

The test uses a 180-unit horizontal path with a 24-unit dash, a 16-unit gap, and butt caps. The cut is at 86 units from the original start. All three rows use the same geometry, viewBox scale, stroke width, dash array, and cap style.

Here are the three cases in a single SVG.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.