HomeCSSAnimationText Stroke Animation Using SVG

Text Stroke Animation Using SVG

Welcome to today’s tutorial. In today’s tutorial, we will learn how to create a text stroke animation using SVG. If you look at the output, it might look complicated but it is super easy and quick to create. I have a playlist of the tutorial of text animation and effects. If you are interested you can check it here.

Video Tutorial:

If you would like to code along with me, you can check out the video tutorial version of this tutorial down below. Also, I post a new tutorial every alternate day on my youtube channel, so be sure to subscribe so you don’t miss any tutorials.


Project Folder Structure:

Let us take a quick look at the project folder structure. The project consists of only two files. First is the HTML document – index.html. Second is the Stylesheet – style.css.


First, we use a vector drawing software or any online SVG editor to create some SVG text. For this purpose, I am using ‘Adobe Illustrator’. we start by creating a new artboard of the size 1280 x 250px. Now in this artboard, you can write any text of your choice, with any font and style. Next, export this as an SVG file. Now open this SVG file and copy the code from this file and place it into the HTML file.


In HTML, we have no other element except the SVG code we just pasted.

<!DOCTYPE html>
<html lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Text Stroke Animation</title>
    <!-- Stylesheet -->
    <link rel="Stylesheet" href="style.css" />
      data-name="Layer 1"
      viewBox="0 0 1280 250"
      <path d="M123.83,76.56H206v22.5H178.92v79.18H150.65V99.06H123.83Z" />
      <path d="M419.92,76.56h82.21v22.5H475v79.18H446.74V99.06H419.92Z" />
      <path d="M647.36,76.56h82.2v22.5H702.45v79.18H674.18V99.06H647.36Z" />


We now code the CSS. We start with our regular CSS reset. This reset removes the unwanted margins and paddings from all the elements.

Next, we set a darker color as the background of our document body. I have used – #00001d as the background-color.

We now centre the SVG element using the transforms.

Now we style the text a little bit by setting the fill to none and stroke to #44ca67. Now we set the values for stroke-width, stroke-dasharray and stroke-dashoffset.

Other Tutorials You Might Like:

We set the stroke-linecap and stroke-linejoin to round to give the text a more modern look. Lastly, we add animation with the name draw-stroke and a duration of 5 seconds. We set the animation direction to forwards.

Finally, we set the keyframes by setting stroke-dashoffset to 0 in the 100% of keyframes.

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
body {
  background-color: #00001d;
svg {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
svg path {
  fill: none;
  stroke: #44ca67;
  stroke-width: 6px;
  stroke-dasharray: 600px;
  stroke-dashoffset: 600px;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: draw-stroke 5s linear forwards;
@keyframes draw-stroke {
  100% {
    stroke-dashoffset: 0;
Your SVG text stroke animation is now ready. If you found any difficulties coding this you can download the source code provided below by clicking on the download code button. Also, all your feedback and suggestions are welcome so please comment on them below.




Please enter your comment!
Please enter your name here

10 − 5 =

Most Popular