SVG Draw-On Animation Not Working? 12 Fixes for stroke-dasharray

A troubleshooting checklist for the CSS "line drawing" logo effect. It covers what each symptom means and the exact fix, with copy-paste code.

You followed a tutorial and added `stroke-dasharray` and `stroke-dashoffset` to your logo, and nothing happens. Or the logo appears all at once, draws only halfway, draws as a double line or snaps back at the end. These faults are common, and nearly all of them have a small fix.

Work through this list from the top. Every fix below uses plain CSS inside the SVG or on your page, with no JavaScript library.

The working baseline (compare yours to this)

Here is a minimal draw-on animation that works. If yours differs, the difference is usually the bug.

``` <svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg"> <style> .draw { fill: transparent; stroke: #111; stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2s ease forwards, fill 0.6s ease 2s forwards; } @keyframes draw { to { stroke-dashoffset: 0; } } @keyframes fill { to { fill: #111; } } @media (prefers-reduced-motion: reduce) { .draw { animation: none; stroke-dashoffset: 0; fill: #111; } } </style> <path class="draw" pathLength="1" d="M10 80 L60 20 L110 80 L160 20" /> </svg> ```

`pathLength="1"` tells the browser to treat the path as 1 unit long, so `dasharray: 1` and `dashoffset: 1` always hide the whole line, whatever its real length.

Symptom: nothing animates at all

1. The path has no stroke. Most exported logos use fills only. A draw-on animation moves the stroke, so if `stroke` is `none` (or missing), there's nothing to see. Fix: give the element a `stroke` color and a `stroke-width`, as in the baseline.

2. The SVG is loaded with an `<img>` tag or as a CSS background, and your CSS lives on the page. A stylesheet on the page can't reach inside an SVG that's loaded as an image. You have two options:

3. Your selector doesn't match anything. Design tools rename things on export. Illustrator, for example, often outputs classes like `.st0` and `.st1`, and other tools put styles straight on attributes. Open the SVG in a text editor and check that the class or ID in your CSS actually appears on the `<path>` elements. If you're unsure, target `path` directly while testing.

4. Your site builder stripped the code. Some CMS and page builders sanitize SVG uploads and remove `<style>` blocks, and some don't allow SVG uploads at all by default. To test, open the SVG file directly in a browser. If it animates there but not on your site, the platform is changing the file. Paste the code inline through a custom HTML or embed block instead.

Symptom: the whole logo shows instantly, then maybe flickers

5. The fill is visible from the start. The stroke may be animating while the solid fill covers it. Set `fill: transparent` at the start and fade the fill in after the stroke finishes, like the second animation in the baseline.

6. An inline style overrides your starting values. If the path has `style="stroke-dashoffset:0"` or similar, it beats your stylesheet's starting value. Delete conflicting inline `style` attributes from the paths.

Symptom: it draws only part of the line, or it jumps

7. Your dash length is shorter than the path. If you hard-code something like `stroke-dasharray: 300` but the path is 850 units long, you'll get gaps and a partial draw. There are two fixes:

8. Some shapes aren't paths. `<text>` elements don't support `pathLength`, so text strokes rarely draw cleanly. Convert text to outlines/paths in your design tool before exporting. Rects, circles and polygons usually work. If one misbehaves in a particular browser, especially Safari, convert it to a `<path>` or use a measured length instead of `pathLength`.

Symptom: it finishes, then disappears or resets

9. Missing `forwards`. Without `animation-fill-mode: forwards` (the `forwards` keyword in the shorthand), the element jumps back to its starting state when the animation ends, so the line vanishes. Add `forwards`. If you want it to loop instead, use `infinite` and make the keyframes end where they began, e.g. `0% { dashoffset: 1 } 50% { dashoffset: 0 } 100% { dashoffset: 1 }`.

Symptom: it animates, but looks wrong

10. You see two outlines instead of one line. This is the most common surprise with real logos. A filled letter is a closed shape, so its stroke traces *both edges* and draws a double line around each letterform. That's correct behavior, not a bug. Your options:

11. It draws from the wrong end or in an odd order. Each path draws from its own start point in the order it appears in the file. To change direction, reverse the path direction in your vector editor, or animate to a negative offset (for example, from `1` to `2` with `pathLength="1"`, or from `L` to `2L` with a measured length L). To change the order, give the paths staggered `animation-delay` values, for example `.p2 { animation-delay: 0.3s; }`.

12. Stroke width looks wrong after scaling. If your viewBox is very large or very small, a `stroke-width` of 2 may be invisible or huge. Pick the stroke width relative to the viewBox numbers, not to the on-screen pixel size.

Pre-launch checklist

Before you put the animated logo in your header, check each item:

  1. Opened the SVG file directly in a browser and it animates.
  2. Checked in at least Chrome, Firefox and Safari (desktop or iOS).
  3. Line ends fully drawn, with no leftover gaps.
  4. Final state stays visible (`forwards`), or the loop is intentional.
  5. A `prefers-reduced-motion` rule shows the finished logo with no animation.
  6. Total animation is short. A header logo that takes many seconds to appear can feel slow.
  7. The `<svg>` has a `viewBox` and either a `role="img"` with a `<title>` or an `aria-label` with your brand name, so screen readers announce it.
  8. Tested on your real platform (WordPress, Webflow, Squarespace, Shopify or similar), not just locally.
  9. File size is reasonable. Remove editor metadata and hidden layers before shipping.

Quick reference: symptom to fix

If you've been through all twelve and your logo still won't behave, the cause is usually in the exported file itself: nested groups, transforms or clip paths from the design tool. Cleaning up the export, or rebuilding the problem paths, normally fixes it.

Want the full done-for-you kit?
LoopMark Studio: Your Animated SVG Logo, Done For You (CSS Draw-On, No JavaScript, 48-Hour ยท $39.00
Get it on Gumroad