How to Make an SVG Logo Draw Itself With CSS (Step-by-Step)

A complete, copy-paste guide to the "line drawing" logo animation for your website header or page loader. It covers preparing the SVG, the stroke-dash technique, filling in the logo, looping, hover effects and reduced motion.

You have probably seen a logo appear as if an invisible pen were tracing it, with the colours fading in at the end. You don't need After Effects, a video file or a JavaScript library for this. It takes a few lines of CSS on an SVG file you probably already have.

This guide walks through the whole process. The finished file is usually a few kilobytes, stays sharp at any size and can be edited in a text editor.

What you need before you start

Step 1: Prepare the SVG file

Most export problems happen here, so don't skip it.

  1. Convert all text to paths. Live text can't be traced. In Illustrator use Type > Create Outlines. In Inkscape use Path > Object to Path. In Figma use Outline Stroke or Flatten.
  2. Remove hidden layers, guides and empty groups. Each one adds clutter to the code.
  3. Ungroup and simplify as much as you can, while keeping each letter or shape as its own path.
  4. Export as plain SVG. In Illustrator, choose "Presentation Attributes" or "Inline Style" for styling. In Inkscape, choose "Plain SVG" or "Optimized SVG" rather than "Inkscape SVG".
  5. Open the file in a text editor. You should see a `viewBox` attribute and one or more `<path d="...">` elements. If you see `<image>` with a long base64 string, the "vector" file is really a picture inside a wrapper. Go back to the source file.

A key fact: the draw-on effect animates strokes (outlines), not fills. Most logos are filled shapes. That's fine. The standard approach is to trace the outline of each shape and then fade the fill in (Step 4).

Step 2: Add a stroke and give each path a known length

Here is a minimal example: one circle path, ready to animate. Paste it straight into an HTML page:

<svg class="logo" viewBox="0 0 120 120" role="img" aria-labelledby="logo-title"> <title id="logo-title">Your Company</title> <path class="draw" pathLength="1" d="M10 60 a50 50 0 1 0 100 0 a50 50 0 1 0 -100 0" fill="none" stroke="#1a1a1a" stroke-width="4" /> </svg>

The `pathLength="1"` attribute tells the browser to treat the path as 1 unit long, whatever its real length is. That way you don't have to measure each path.

If a browser ever draws the dashes wrongly, measure the real lengths instead. Open the page, open the developer console and run:

document.querySelectorAll('.draw').forEach(p => console.log(p.getTotalLength()))

Then use those numbers in place of `1` in the CSS below. Remove `pathLength`.

Step 3: The draw-on CSS

.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s ease-in-out forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }

How it works: `stroke-dasharray: 1` turns the stroke into one dash as long as the whole path, followed by an equally long gap. `stroke-dashoffset: 1` shifts the pattern so only the gap shows, which means the path starts invisible. Animating the offset to 0 slides the dash into place, and the line looks like it is being drawn. `forwards` keeps the final frame visible after the animation ends.

Fixing a stray dot at the start: with `stroke-linecap="round"` or `"square"`, a small cap can show before the animation begins. Use `stroke-linecap="butt"`, or set both values to `1.01` instead of `1`.

Step 4: Fade in the fill after the line finishes

For a filled logo, use two copies of each shape: an outline that draws and a filled version that fades in. In practice you can often use one path with both properties:

<path class="draw fill-in" pathLength="1" d="..." fill="#e85d2a" stroke="#e85d2a" stroke-width="2" />

.fill-in { fill-opacity: 0; animation: draw 1.6s ease-in-out forwards, fill-in 0.5s ease 1.4s forwards; }

@keyframes fill-in { to { fill-opacity: 1; } }

The fill starts at 1.4s, slightly before the line finishes at 1.6s. That overlap makes the change feel smooth rather than mechanical.

Step 5: Stagger multiple paths (letter by letter)

When a logo has several paths, starting them all at once looks busy. Give each path a number and calculate its delay:

<path class="draw" style="--i:0" pathLength="1" d="..." /> <path class="draw" style="--i:1" pathLength="1" d="..." /> <path class="draw" style="--i:2" pathLength="1" d="..." />

.draw { animation-delay: calc(var(--i) * 0.15s); }

Delays between 0.1s and 0.2s per path usually read as one continuous motion. Longer gaps feel like separate events.

Step 6: Turn it into a looping loader

For a page loader, let it draw and undraw forever:

.loader .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.8s ease-in-out infinite alternate; }

`alternate` plays the animation forward, then backward, so you avoid an abrupt jump back to empty. Keep loaders simple. One or two paths look better than a full wordmark redrawing on a loop.

Step 7: Add a hover state

A subtle hover effect works well for a header logo that links to your homepage:

.logo .draw { transition: stroke 0.3s ease, transform 0.3s ease; transform-origin: center; transform-box: fill-box; }

.logo:hover .draw { stroke: #e85d2a; transform: scale(1.04); }

Hover only works when the SVG is inline in the page (see Step 9). Touch devices have no real hover, so don't put anything important behind it.

Step 8: Respect reduced-motion settings

Some visitors set their device to reduce motion, for example because of vestibular disorders. Always include this:

@media (prefers-reduced-motion: reduce) { .draw, .fill-in { animation: none; stroke-dashoffset: 0; fill-opacity: 1; } }

Those visitors see the finished logo straight away. To test it, turn on "Reduce motion" in your operating system's accessibility settings and reload the page.

Step 9: Choose how to embed it

How you place the SVG changes what works:

For the `<img>` approach, put the styles inside the SVG file itself:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120"> <style> .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s ease-in-out forwards; } @keyframes draw { to { stroke-dashoffset: 0; } } @media (prefers-reduced-motion: reduce) { .draw { animation: none; stroke-dashoffset: 0; } } </style> <path class="draw" pathLength="1" d="..." fill="none" stroke="#1a1a1a" stroke-width="4"/> </svg>

(The `xmlns` value is a required namespace identifier, not a link. The browser needs it to read the file as SVG.)

Timing cheat sheet

Pre-launch checklist

Common problems and fixes

Once you've built one, the same structure works for every logo. Only the paths and the timing change.

More templates and kits
Browse the Quillwork shop