Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="">
  <br><br>
  <h2>
    <a target="_blank" href="https://codepen.io/cariefisher/pen/abVyvOd">Go to step 4</a>
  </h2>
</div>
              
            
!

CSS

              
                /* Let's take out the inline styles from the original SVG and add them to a CSS file. Doing this will give us more control over the look and feel of the SVG, plus it allows us to create a reverse design using prefers-color-scheme media query. To simplify things for later on, let's rename the IDs to easily know what we are modifying.

There are a lot of styling options for SVGs...too many to list at least in this CodePen! Check out this article on "SVG Properties and CSS" by Katherine Kato for more details about currently supported options, plus some future SVG 2 options : https://css-tricks.com/svg-properties-and-css/

Note: you can create either a dark theme or a light theme - it just depends on what theme you start with as to what the alternate experience is. Keep in mind - both experiences need to meet WCAG color contrast ratio guidelines. One theme cannot just be your "accessible" theme and the other your "regular" theme. All experiences need to be inclusive. 

Can I Use: https://caniuse.com/?search=prefers-color-scheme */

@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;
}

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

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

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