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

              
                <!--Setup Symbols here -->
<svg class="symbol" >
  <symbol id="tablet" viewBox="-10 00 260 300" >
    <g >
      <path d="M202.986,317 L12.097,317 C5.462,317 0.083,311.623 0.083,304.99 L0.083,12.093 C0.083,5.46 5.461,0.083 12.097,0.083 L202.986,0.083 C209.622,0.083 215,5.46 215,12.093 L215,304.99 C215,311.623 209.622,317 202.986,317 Z" id="bezel-2" stroke-width="3" fill="#FDFDFD"></path>
      <rect id="screen" fill="#FFFFFF" x="17" y="32" width="181.999" height="252.917"></rect>
      <circle id="lock" cx="108.021" cy="300.021" r="8.021"></circle>
      <circle id="camera" cx="106.99" cy="16.99" r="2.99"></circle>
    </g>
  </symbol>   
</svg>

<svg class="symbol">
  <symbol id="chevron" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--1' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>

<svg class="symbol blue--line-1 red--line-2">
  <symbol id="color-chevron" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--2' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>
<svg class="symbol brown--line-1 green--line-2">
  <symbol id="color-chevron2" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--2' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>

<svg class="symbol">
  <symbol class="blue--line-1 red--line-2" id="color-chevron3" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--2' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>
<svg class="symbol">
  <symbol class="brown--line-1 green--line-2" id="color-chevron4" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--2' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>

<svg class="symbol ">
  <symbol class="css-props" id="props-chevron" viewBox="0 0 100 60" >
    <line class='line line--1' x1="50" y1="50" x2="10" y2="10" stroke-width="10" stroke-linecap="round"></line>
    <line class='line line--2' x1="50" y1="50" x2="90" y2="10" stroke-width="10" stroke-linecap="round"></line>
  </symbol>
</svg>





<!--  Re-Use Symbols here -->
<!-- xlink required for safari -->

<h2>SVG w/ Single Style</h2>
<h3>Reuse (w/ only <code>href</code>)</h3>
  <p><em>Works in Chrome, Edge 14+, IE11, Friefox, Opera (Not Safari)</em></p>
<div>
  <svg stroke="red" width="50" height="75" ><use href="#tablet" /></svg>
  <svg stroke="green" width="50" height="75" ><use href="#tablet" /></svg>
  <span class="icon--blue"><svg width="50" height="75"><use href="#tablet"></use></svg></span>
</div>

<h3>Reuse (w/ <code>xlink:href</code>)</h3>
<p><em>Works in all browsers</em></p>
<svg stroke='red' fill='darkgrey' width="50" height="75">
    <use xlink:href="#tablet" />
</svg>

<svg fill='darkgrey' stroke='green' width="50" height="75">
    <use xlink:href="#tablet" />
</svg>

<svg class="icon icon--blue" width="50" height="75">
    <use xlink:href="#tablet" />
</svg>






<h2>SVGs w/ multiple styles</h2>

<h3>Multiple <code>Symbol</code> tags (w/ class on <code>SVG</code>)</h3>
<p><em>Works in Chrome, Edge 14+, IE11, Opera, safari (not in Firefox)</em></p>
<div>
    <svg width="4em" height="40px" ><use xlink:href="#color-chevron2"></use></svg>
    <svg width="4em" height="40px"><use xlink:href="#color-chevron"></use></svg>
</div>

<h3>Multiple <code>Symbol</code> tags (w/ class on <code>symbol</code>)</h3>
<p><em>Works in all browsers</em></p>
<div>
    <svg width="4em" height="40px" ><use xlink:href="#color-chevron3"></use></svg>
    <svg width="4em" height="40px"><use xlink:href="#color-chevron4"></use></svg>
</div>

<h2>SVGs w/ multiple styles + Custom Props</h2>
<h3>Single <code>symbol</code> Styled using CSS custom properties</h3>
  <p><em>Works in All Browsers (which support custom props i.e. Chrome, Edge 16+, Opera, Firefox, Safari; not IE or Edge 14/15)</em></p>
  <div>
    <svg width="4em" height="40px"><use xlink:href="#props-chevron"></use></svg>
    <svg class='reuse-props' width="4em" height="40px"><use xlink:href="#props-chevron"></use></svg>
  </div>
  
  
  
  
  <h2>Resizing SVGs symbols</h2>
  <p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1415155">https://bugzilla.mozilla.org/show_bug.cgi?id=1415155</a></p>
  <p>Firefox is the only browser to correctly respect the symbol size</p>
  <p><em>Size matches outer SVG in Chrome, Safari, Edge 14+, IE Opera</em></p>
  <span><svg width="82px" height="16px" class="sr-only"><symbol id="star" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 64 512 512" width="150" height="150" class="icon"><path transform="scale(1, -1) translate(0, -512)" d="M342 147q-8 -5 -5 -14l46 -140l-120 87q-7 5 -14 0l-120 -87l46 140q3 9 -5 14l-119 87h147q10 0 12 9l46 140l46 -140q2 -9 11 -9h148zM499 259h-176l-55 168q-3 9 -12 9t-12 -9l-55 -168h-176q-10 0 -12.5 -8.5t4.5 -13.5l143 -104l-54 -169q-3 -8 4 -13.5t15 -0.5 l143 104l143 -104q3 -2 7 -2t8 2q7 6 4 14l-54 169l143 104q7 5 4 13.5t-12 8.5v0z"></path></symbol></svg><svg width="82px" height="16px"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#star"></use></svg></span>
  
  
  
  
  <h2>SVG Reuse w/ Linear Gradients</h2>
  <p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1415180">https://bugzilla.mozilla.org/show_bug.cgi?id=1415180</a></p>
  <p><em>Gradient should show. Works in Chrome, Safari, Edge 14+, IE Opera (not in Firefox)</em></p>
  
<svg width="35" height="20" class="sr-only">
  <symbol id="fast-track" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 587.1 287.3" class="icon icon--fast-track">
    <style type="text/css">
      .fast-track-icon__gradient{fill:url(#fast-track-icon__gradient);}
    </style>
    <g>
  <linearGradient id="fast-track-icon__gradient" gradientUnits="userSpaceOnUse" x1="460.6738" y1="285.375" x2="460.6738" y2="1.9141" gradientTransform="matrix(1 0 -0.3719 1 -119.0996 0)"><stop offset="0" style="stop-color:#751A02"></stop><stop offset="2.873510e-002" style="stop-color:#891D08"></stop><stop offset="7.119306e-002" style="stop-color:#9F210F"></stop><stop offset="0.1214" style="stop-color:#B02414"></stop><stop offset="0.1834" style="stop-color:#BB2617"></stop><stop offset="0.2705" style="stop-color:#C22819"></stop><stop offset="0.5123" style="stop-color:#C4281A"></stop><stop offset="0.7425" style="stop-color:#C22819"></stop><stop offset="0.8254" style="stop-color:#BB2617"></stop><stop offset="0.8845" style="stop-color:#B02414"></stop><stop offset="0.9322" style="stop-color:#9F210F"></stop><stop offset="0.9726" style="stop-color:#891D08"></stop><stop offset="1" style="stop-color:#751A02"></stop></linearGradient>
    
  </g>
    <g><path class="fast-track-icon__gradient" d="M292,68.4h43l-5.2,133.8h-37.5l9-91l-52,91h-39.1L292,68.4z M372.4,68.4L375,1.9h-33.5l-6.6,66.4H372.4z M292,68.4l37.9-66.4h-36.4l-40.6,66.4H292z M249.3,202.1l-50.9,83.2h37.1l23.1-40.5l-4,40.5H289l3.3-83.2H249.3z"></path>
      <path d="M190.9,59.2h40.4L214.1,87h-33.4l-18.1,48.7H130L179.8,1.9h88L249,29.6h-46.9L190.9,59.2z"></path>
      <path class="fast-track-icon__text" d="M475.6,46.8l-1.4,3.8h-32.5l1.4-3.8c5-13.6,1-19.1-8.4-19.1c-9.4,0-14.3,4.8-16.4,10.5 c-8.9,23.5,58,9.6,39.4,59.2c-9.5,25.8-35.7,40.1-62.8,40.1c-27.1,0-43-13.4-30.5-46.8l0.7-1.9h32.5l-0.7,1.9 c-5.1,13.6-0.3,19.1,9.1,19.1c9.4,0,15.8-3.6,18.4-10.5c8.6-23.1-57.4-10.9-39.4-59.2C394.6,14.3,418,0,445.2,0 C472.3,0,488,13.4,475.6,46.8z"></path>
      <path d="M72.1,179.3L32.5,285.4H0l39.5-106.1H13.1l10.4-27.7H111l-17.4,27.7H72.1z"></path>
      <path d="M173.8,151.6c27.1,0,40.4,10.5,31.5,34.4l-3.7,9.6c-4.7,12.6-13.9,22.4-28,27.1c6.3,4.6,8.2,13.2,5,27.3 l-7.6,35.4h-32.4l7.4-32.7c2.8-12.4-0.6-15.1-9.3-15.1h-12.1l-17.9,47.8H74.3l49.8-133.8H173.8z M146.2,179.3L135,209.9h17.2 c8.5,0,13.8-5.5,16.7-13.4l1.4-3.8c2.9-7.8,1.7-13.4-6.8-13.4H146.2z"></path>
      <path d="M437.4,196.5l-33.9,3.8l1.4-3.8c5-13.6,1-19.1-8.4-19.1c-9.4,0-17.4,5.5-22.4,19.1l-16.3,44 c-5.1,13.6-1.2,19.1,8.2,19.1c9.4,0,17.4-5.5,22.6-19.1l0.7-1.9h32.5l-0.7,1.9c-12.5,33.4-38.2,46.8-65.3,46.8 c-27.1,0-42.6-14.3-30.2-47.8l15.6-42c12.5-33.4,38.7-47.8,65.8-47.8C434,149.7,449.7,163.1,437.4,196.5z"></path>
      <path d="M528.9,285.4h-39.2l-15-58.7l-21.7,58.7h-32.5l49.8-133.8h32.5l-21.3,57.1l58-57.1h37.4l-68.3,64.2 L528.9,285.4z"></path>
      <path class="fast-track-icon__text" d="M548.1,29.6l-39.5,106.1h-32.5l39.5-106.1h-26.4l10.4-27.7h87.5l-17.4,27.7H548.1z"></path>
        </symbol></svg>
  <svg width="35" height="20"><use xlink:href="#fast-track"></use></svg>

  
  <p><em>Moving the Gradient outside the <code>symbol</code>. Works in all browsers</em></p>
  
  <div>
    <svg width="35" height="20" class="sr-only">
     <defs>
       <linearGradient id="id-outside-symbol" gradientUnits="userSpaceOnUse" x1="460.6738" y1="285.375" x2="460.6738" y2="1.9141" gradientTransform="matrix(1 0 -0.3719 1 -119.0996 0)"><stop offset="0" style="stop-color:#751A02"></stop><stop offset="2.873510e-002" style="stop-color:#891D08"></stop><stop offset="7.119306e-002" style="stop-color:#9F210F"></stop><stop offset="0.1214" style="stop-color:#B02414"></stop><stop offset="0.1834" style="stop-color:#BB2617"></stop><stop offset="0.2705" style="stop-color:#C22819"></stop><stop offset="0.5123" style="stop-color:#C4281A"></stop><stop offset="0.7425" style="stop-color:#C22819"></stop><stop offset="0.8254" style="stop-color:#BB2617"></stop><stop offset="0.8845" style="stop-color:#B02414"></stop><stop offset="0.9322" style="stop-color:#9F210F"></stop><stop offset="0.9726" style="stop-color:#891D08"></stop><stop offset="1" style="stop-color:#751A02"></stop></linearGradient>
       
     </defs>
      <symbol id='fast-track-outside' viewBox="0 0 587.1 287.3">
        <style type="text/css">
          .id-outside-symbol{fill:url(#id-outside-symbol);}
        </style>
        <g><path class="id-outside-symbol" d="M292,68.4h43l-5.2,133.8h-37.5l9-91l-52,91h-39.1L292,68.4z M372.4,68.4L375,1.9h-33.5l-6.6,66.4H372.4z M292,68.4l37.9-66.4h-36.4l-40.6,66.4H292z M249.3,202.1l-50.9,83.2h37.1l23.1-40.5l-4,40.5H289l3.3-83.2H249.3z"></path>
          <path  d="M190.9,59.2h40.4L214.1,87h-33.4l-18.1,48.7H130L179.8,1.9h88L249,29.6h-46.9L190.9,59.2z"></path>
          <path d="M475.6,46.8l-1.4,3.8h-32.5l1.4-3.8c5-13.6,1-19.1-8.4-19.1c-9.4,0-14.3,4.8-16.4,10.5 c-8.9,23.5,58,9.6,39.4,59.2c-9.5,25.8-35.7,40.1-62.8,40.1c-27.1,0-43-13.4-30.5-46.8l0.7-1.9h32.5l-0.7,1.9 c-5.1,13.6-0.3,19.1,9.1,19.1c9.4,0,15.8-3.6,18.4-10.5c8.6-23.1-57.4-10.9-39.4-59.2C394.6,14.3,418,0,445.2,0 C472.3,0,488,13.4,475.6,46.8z"></path>
          <path d="M72.1,179.3L32.5,285.4H0l39.5-106.1H13.1l10.4-27.7H111l-17.4,27.7H72.1z"></path>
          <path d="M173.8,151.6c27.1,0,40.4,10.5,31.5,34.4l-3.7,9.6c-4.7,12.6-13.9,22.4-28,27.1c6.3,4.6,8.2,13.2,5,27.3 l-7.6,35.4h-32.4l7.4-32.7c2.8-12.4-0.6-15.1-9.3-15.1h-12.1l-17.9,47.8H74.3l49.8-133.8H173.8z M146.2,179.3L135,209.9h17.2 c8.5,0,13.8-5.5,16.7-13.4l1.4-3.8c2.9-7.8,1.7-13.4-6.8-13.4H146.2z"></path>
          <path d="M437.4,196.5l-33.9,3.8l1.4-3.8c5-13.6,1-19.1-8.4-19.1c-9.4,0-17.4,5.5-22.4,19.1l-16.3,44 c-5.1,13.6-1.2,19.1,8.2,19.1c9.4,0,17.4-5.5,22.6-19.1l0.7-1.9h32.5l-0.7,1.9c-12.5,33.4-38.2,46.8-65.3,46.8 c-27.1,0-42.6-14.3-30.2-47.8l15.6-42c12.5-33.4,38.7-47.8,65.8-47.8C434,149.7,449.7,163.1,437.4,196.5z"></path>
          <path d="M528.9,285.4h-39.2l-15-58.7l-21.7,58.7h-32.5l49.8-133.8h32.5l-21.3,57.1l58-57.1h37.4l-68.3,64.2 L528.9,285.4z"></path>
          <path d="M548.1,29.6l-39.5,106.1h-32.5l39.5-106.1h-26.4l10.4-27.7h87.5l-17.4,27.7H548.1z"></path>
            
          </symbol>
        </svg>
      <svg width="35" height="20"><use xlink:href="#fast-track-outside"></use>
      </svg>

      </span>
              
            
!

CSS

              
                  .symbol { display: none; }
  .icon--blue {
    stroke:blue;
    fill:darkgrey;
  }
  .blue--line-1 .line--1 {
    stroke:blue;
  }
  .red--line-2 .line--2 {
    stroke:red;
  }
  .brown--line-1 .line--1 {
    stroke:brown;
  }
  .green--line-2 .line--2 {
    stroke:green;
  }

:root {
  --line-1: brown;
  --line-2: green;
}
.css-props .line--1 {
    stroke: var(--line-1);
}
.css-props .line--2 {
    stroke: var(--line-2);
}
.reuse-props {
  --line-1: red;
  --line-2: blue;  
}
              
            
!

JS

              
                
              
            
!
999px

Console