📘 Theory

Styling inline SVG with CSS

Inline SVG is usually the best choice when you want full visual control.

1

When the SVG lives directly in the HTML, you can target its `path`, `circle`, `rect` or `line` elements like any other DOM node.

2

That makes theme switching much easier because CSS variables, hover states and focus states can all style the same illustration.

Drawing a line with `dasharray` and `dashoffset`

This classic technique simulates a path being drawn over time.

1

The common pattern sets `stroke-dasharray` and `stroke-dashoffset` to the full path length, then animates the offset down to zero.

2

It works well for logos, progress traces, checkmarks and scroll-based reveal effects where a static line would feel flat.

🧪 Learn by doing

Example Demo: themeable SVG icon Use CSS hover styles to swap the icon color without changing the markup.
Example Interactive demo: scroll-driven SVG strokes with CSS only Explore how `pathLength`, `stroke-dasharray` and `stroke-dashoffset` can work together without JavaScript.
Example Interactive demo: multiple SVG curves with staggered timing See how several `path` elements can animate at different rates to build a richer composition using only CSS.
Example Interactive demo: full-width SVG line animation Review a wider version with several curves and a stretched `viewBox` for larger layouts.
Example Interactive demo: JavaScript-controlled SVG stroke animation Compare the JavaScript approach so you can judge when CSS is enough and when measuring the path becomes useful.
Example Interactive demo: scroll reveal with SVG lines Combine `view()` and SVG strokes to reveal paths as the block enters the viewport.

🏁 Challenges

Challenge Challenge: animate an SVG stroke Create a drawing effect with `stroke-dashoffset` and keyframes.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com