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 a black and yellow cartoon bee plus 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="">
</div>
              
            
!

CSS

              
                /* Finally, let's add a reduced movement expereince to our SVG, keeping in mind the related WCAG requirements around animation, then give our users an alternate experience in case they prefer no/less movement.

Val Head's article "Accessible Web Animation: The WCAG on Animation Explained" is a great high-level resource for WCAG motion/animation requirements: https://css-tricks.com/accessible-web-animation-the-wcag-on-animation-explained 

Tatiana Mac's article "prefers-reduced-motion: Taking a no-motion-first approach to animations" flips the idea of reduced motion on its head by suggesting we start with reduced motion and then add it only if our user doesn't have a motion preference set: https://www.tatianamac.com/posts/prefers-reduced-motion/ 

Can I Use: https://caniuse.com/?search=prefers-reduced-motion 

I also combined the image alt information to have all of the information read once to a screen reader instead of in two pieces. This is not a requirement, but can help enhance the user expereince. */

@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 changes for prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  #vday {
    animation: none;
  }

  #heart {
    fill: #6a329f;
    animation: none;
  }
}

/* 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