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

              
                <!-- credit to Andy Bell for this tip https://codepen.io/andybelldesign/pen/NoZzav -->

<a class="call-to-action" href="/">
  <span>I’m a link</span>
  <svg 
       class="cta-icon" aria-hidden="true" 
       width="1em" height="1em" 
       viewBox="0 0 14 13"
    xmlns="http://www.w3.org/2000/svg">
    <path 
          fill="currentColor" fill-rule="evenodd" 
          d="M3.49.868l7.683 3.634a2 2 0 0 1 .052 3.59l-7.682 3.913a2 2 0 0 1-2.908-1.782V2.676A2 2 0 0 1 3.49.868z">
    </path>
  </svg>
</a>

<a class="call-to-action call-to-action-alt" href="/">
  <span>I’m a large link</span>
  <svg 
       class="cta-icon" aria-hidden="true" 
       width="1em" height="1em" 
       viewBox="0 0 14 13"
    xmlns="http://www.w3.org/2000/svg">
    <path 
          fill="currentColor" fill-rule="evenodd" 
          d="M3.49.868l7.683 3.634a2 2 0 0 1 .052 3.59l-7.682 3.913a2 2 0 0 1-2.908-1.782V2.676A2 2 0 0 1 3.49.868z">
    </path>
  </svg>
</a>

<section id="notes">
  <h2>Notes</h2>
  <ul>
    <li>By applying width and height of 1em to our SVG icon (using HTML attributes) it is predictably sized by default.</li>
    <li>1em = the font-size of its parent element, the a.call-to-action.</li>
    <li>Due to its em-based dimensions, a "link icon" pattern of this type is flexible – it will scale with its parent anchor’s font-size.</li>
    <li>If need be it can also have its size further tweaked in a relative/flexible way via an em-based <code>font-size</code>, and thus will still scale up and down based on the font-size of its parent.</li>
    <li>This technique requires the “viewbox” attribute being present on the svg</li>
    <li>We apply the width and height =1em as inline attributes on the SVG rather than using CSS only because the inline approach avoids potentially massive icons in cases where CSS doesn’t load.</li>
    <li>To get the colour matching, apply fill="currentColor" as an inline attribute on the svg’s path.</li>
    <li>Now, when you apply a hover colour to the anchor in CSS, the icon will just pick that up.</li>
    <li>Applying inline-flex to the anchor makes the vertical-alignment of text and icon easier.</li>
    <li>Add aria-hidden on the icon because it’s mainly decorative so we don’t want it read out by screen readers.</li>
    <li>Credit to Andy Bell for the tip <a href="https://codepen.io/andybelldesign/pen/NoZzav">https://codepen.io/andybelldesign/pen/NoZzav</a></li>

  </ul>
</section>
              
            
!

CSS

              
                a { color: rgb(183, 65, 14); }
a:hover { color: #6A2000; }
.call-to-action {
  display: inline-flex;
  align-items: center;
  font-weight: bold;
}
.call-to-action-alt {
  font-size: 2rem; 
}
.cta-icon {
  margin-left: .5em;
  font-size: .8em;
}



/* Non-important stuff */
:root {
  font-size: 1.75rem;
  color: #303030;
  font-family: Georgia, serif;
}
body {
  line-height: 1.4;
  display: grid;
  height: 100vh;
  place-items: center;
}
a { font-family: Helvetica, Arial, sans-serif; }
#notes {
  display: none;
  max-width: 75vw;
}
@media screen and (min-width: 30em) {
  #notes {
    display: block;
  } 
}
#notes h2 {
  font-weight: 700;
  margin-bottom: .5em;
}
#notes ul {
  list-style: disc;
}
#notes ul li {
  font-size: .7rem;
  margin-bottom: .5em;
}
              
            
!

JS

              
                
              
            
!
999px

Console