Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="wrapper"><svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 650 590" width="635" height="550" id="vday" role="img">
    <title>Large red heart with text that says Bee my valentine?</title>
    <g id="heart">
      <path d="M 297.29747,550.86823 C 283.52243,535.43191 249.1268,505.33855 220.86277,483.99412 C 137.11867,420.75228 125.72108,411.5999 91.719238,380.29088 C 29.03471,322.57071 2.413622,264.58086 2.5048478,185.95124 C 2.5493594,147.56739 5.1656152,132.77929 15.914734,110.15398 C 34.151433,71.768267 61.014996,43.244667 95.360052,25.799457 C 119.68545,13.443675 131.6827,7.9542046 172.30448,7.7296236 C 214.79777,7.4947896 223.74311,12.449347 248.73919,26.181459 C 279.1637,42.895777 310.47909,78.617167 316.95242,103.99205 L 320.95052,119.66445 L 330.81015,98.079942 C 386.52632,-23.892986 564.40851,-22.06811 626.31244,101.11153 C 645.95011,140.18758 648.10608,223.6247 630.69256,270.6244 C 607.97729,331.93377 565.31255,378.67493 466.68622,450.30098 C 402.0054,497.27462 328.80148,568.34684 323.70555,578.32901 C 317.79007,589.91654 323.42339,580.14491 297.29747,550.86823 z" />
    </g>
    <g id="message" aria-hidden="true"><text x="150" y="200" id="beemy">Bee My</text><text x="110" y="300" id="val">Valentine?</text>
    </g>
  </svg><img id="bee" src="https://upload.wikimedia.org/wikipedia/commons/9/91/Abeille-bee.svg" alt="Black and yellow cartoon bee">
  <br><br>
  <h2>
    <a target="_blank" href="https://codepen.io/cariefisher/pen/ZEaJbpz">Go to step 5</a>
  </h2>
</div>
              
            
!

CSS

              
                /* Let's now add some movement to our SVG. Since we are not using <text> to render the typography, we are somewhat limited by what we can animate directly. However, there are some interesting masking techniques that we can add to create a scrawling effect, even if we don't have direct access to the font itself.

In this demo, I am simply changing the color of the heart and not altering the typography...but if that is something you are interested in, see the resources below.

Trapti Rahangdale's article "How to Get Handwriting Animation With Irregular SVG Strokes" on SVG masking: https://css-tricks.com/how-to-get-handwriting-animation-with-irregular-svg-strokes

Cassie Evan's article "Creating my logo animation" on SVG stroke-dasharray: https://www.cassie.codes/posts/creating-my-logo-animation/#heading-svg-stroke-dasharray

My simple CodePen example using the <text> element to draw out words - plus it includes prefers-reduced-motion code: https://codepen.io/cariefisher/pen/rNVLxoJ
*/

@import url("https://fonts.googleapis.com/css2?family=Open+Sans&family=Parisienne&display=swap");

body {
  font-family: "Parisienne", cursive;
  margin: 2rem;
}

a {
  color: #000000;
  text-decoration: underline;
  margin-left: 2rem;
  font-family: "Open Sans", sans-serif;
}

#wrapper {
  position: relative;
  width: 650px;
  height: 590px;
}

/* heart */
#heart {
  fill: #ff0000;
  stroke: #000000;
  stroke-width: 15;
  stroke-dasharray: 1, 30;
  stroke-linecap: round;
  fill-opacity: 1;
  fill-rule: nonzero;
  animation: rainbow 25s linear infinite;
}

/* text */
#message {
  fill: #000000;
  font-size: 6rem;
  font-weight: bold;
}

#vday {
  animation: dash 60s linear infinite;
}

/* bee */
#bee {
  width: 200px;
  position: absolute;
  bottom: 23%;
  left: 33%;
}

/* Heart color animation */
@keyframes rainbow {
  0%,
  100% {
    fill: #ee2722;
  }
  25% {
    fill: #dd00f3;
  }
  50% {
    fill: #6a329f;
  }
  75% {
    fill: #ffb6c1;
  }
}

@-webkit-keyframes dash {
  from {
    stroke-dashoffset: 1000;
    fill: transparent;
  }

  to {
    stroke-dashoffset: 0;
    fill: #000000;
  }
}

/* CSS + animation for default / light mode theme */
@media (prefers-color-scheme: dark) {
  body {
    background: #000000;
  }

  a {
    color: #ffffff;
    text-decoration: underline;
  }

  #heart {
    stroke: #ffffff;
  }

  #message {
    fill: #ffffff;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console