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

              
                <article>
<h2>Proof of Concept:</h2>
<h1>SVG Inside Border/Middle Border/Outside Border using CSS</h1>
<h3>No calculations, no math, no hacks, no dependancies, no plug-ins/libraries, no cross-browser/platform issues... no joke.</h3>

<section>
   <div></div>
   <svg id="example1" class="inside" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 495 500">
      <def><path id="dryPath1" d="M247.5 0l81.6 157.1L495 191 379.4 322l21 178-153-76.2-153 76.2 21-178L0 191 166 157 247.4.1"/></def>
      <mask id="borderMasker1"><use href="#dryPath1"/></mask>
      <use href="#dryPath1" mask="url(#borderMasker1)" />
   </svg>

   <svg id="example2" class="standard" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 495 500">
      <def><path id="dryPath2" d="M247.5 0l81.6 157.1L495 191 379.4 322l21 178-153-76.2-153 76.2 21-178L0 191 166 157 247.4.1"/></def>
      <mask id="borderMasker2"><use href="#dryPath2"/></mask>
      <use href="#dryPath2" mask="url(#borderMasker2)" />
   </svg>
    
   <svg id="example3" class="outside" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 495 500">
      <def><path id="dryPath3" d="M247.5 0l81.6 157.1L495 191 379.4 322l21 178-153-76.2-153 76.2 21-178L0 191 166 157 247.4.1"/></def>
      <mask id="borderMasker3"><use href="#dryPath3"/></mask>
      <use href="#dryPath3" mask="url(#borderMasker3)" />
   </svg>

</section>
   <p><em><strong>Dev Logs: </strong></em>So, bizzarely, the entirety of the issues I've run into with this approach center not around
      the SVG stuff, but rather around the way the different browsers treat CSS variables and how that,
      in turn, influences their interpretation of the SVG spec.
   <br><br>
   <em>Example:</em><br>
   The <code>--stroke</code> variable (<em>ln:2, inside the <code>root</code></em>) sets the line thickness for all 3 stars.<br>
      If I set a unit to the value (e.g. <code>--stroke:40<u><b>px</b></u>;</code>): <br>
      - Chrome shrugs it off and works fine<br>
      - Firefox will break<br>
      - Safari is happy<br>
      - IE/Edge will continue to make my life miserable in some other, unrelated capacities.<br><br>
      Removing the unit (e.g. <code>--stroke:40;</code>):<br>
      - Chrome still shrugs it off and still works fine<br>
      - Firefox is happy <br>
      - Safari will break<br>
      - IE/Edge will continue to make my life miserable in some other, unrelated capacities.
   <br><br>
      I have yet to find a combination using CSS variable rollover defaults, secondary variables, hard-set
      values, etc. that makes everyone happy (or will conclusively dispose of IE/Edge), though contributions are welcome. 
      I've dented my wall enough.
      <br>
      <br>
      -- @JJ / ZenAtWork for Nerdy Deeds, LLC.
   </p>
</article>
              
            
!

CSS

              
                :root{
   --stroke:40;
   /* DEFAULT BEHAVIOR - Green Middle Star CSS Defs */
   svg:not(.inside):not(.outside) {  // <- This bizzareness is to accomodate some weird inheritence issue in FIREFOX of all things
      & > use {
         stroke:#0F0;
         fill:#060;
         stroke-width:var(--stroke);
      }
      & > mask > use {
         fill:white;
         stroke:white;
         stroke-width:var(--stroke);
         
      }
   }
   
   /* Blue Outside Star CSS Defs */
   svg.outside { 
      stroke-width:calc(var(--stroke) * 2);
      paint-order: stroke fill;
      
      & > use {
         stroke:  #00f;
         fill:    #006;
      }
      & > mask > use {
         fill:    #fff;
         stroke:  #fff;
      }
   }

   /* Red Inside Star CSS Defs */
   svg.inside { 
      stroke-width:calc(var(--stroke) * 2);
      paint-order: fill stroke;
      
      & > use {
         stroke:  #f00;
         fill:    #600;
      }
      & > mask > use {
         fill:    #fff;
         stroke:  #fff;
         stroke-width:0;
      }
   }
}   

/* THE STYLES BELOW ARE ONLY FOR ILLUSTRATION IN THIS DEMO AND ARE NOT NEEDED FOR THE BORDER-POSITIONING */
* { box-sizing:border-box; font-family:'Open Sans', sans-serif; }
h1, h2, h3 { text-align:center; }
article {
   max-width:1200px;
   margin: 0 auto;
   
}
section {
   float:left; transform:scale(0.25); 
   margin-left:25px;
   div { 
      height: 500px; border: 2px solid black; width: 1600px; top: 100px; left: -2px; position:absolute;
      &::before { content: ''; height: 298px; border: 2px dashed #0AA9; position: absolute; width: 100%; top: 96px; left: -2px; z-index: 0; }
      &::after { content: ''; height: 98px; border: 2px dashed #0AA9; position: absolute; width: 100%; top: 196px; left: -2px; z-index: 10000; }
   }
   svg { 
      position: absolute; z-index: -1; top: 100px; height: 500px; 
      &#example1, &#control { left: 50px; }
      &#example2 { left: 554px; }
      &#example3 { left: 1058px; }
   }
}

p {
   display:block;
   margin:0 100px 0 450px;
   line-height:1.6;
   font-size:1em;
   // float:right;
}

pre, code {
   background-color:#EEE;
   border:1px solid #AAA;
   padding:1px 4px;
   &, & * {
      font-family:monospace;
      
   }
}
              
            
!

JS

              
                
              
            
!
999px

Console