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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <h1>Font-Face Descriptor Playground</h1>
<p>Adjust the font metric overrides (f-mods) below to match a fallback font with your webfont!<br>Note that the fallback font must be declared as its own font-face with a local source.</p>
<div class="container">
  <h2>CSS</h2>
  <style class="cssbox" contenteditable>
 /* set your custom webfont */
  @font-face {
    font-family: custom-font;
    src: url('https://simonhearne.com/assets/fonts/dosis-v17-latin-variable.woff2') format('woff2');
  }

  /* adjust fallback font overrides */
  @font-face {
    font-family: fallback-font;
    ascent-override: 100%;
    descent-override: 20%;
    line-gap-override: normal;
    advance-override: 10;
    src: local(Arial);
  }
  
  /* adjust fallback letter and word spacing */
  .fallback {
    letter-spacing: -1.1px;
    word-spacing: -0.2px;
  }
  </style>
  <h2>Font-face Descriptor Result</h2>
  <p>
    <label for="flashToggle">Flash fonts: 
      <input type="checkbox" id="flashToggle" name="flashToggle"/>
    </label>
  </p>
  <div class="text-container">
    <div class="fallback" id="reference">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse gravida nisl ac velit dignissim lacinia. Etiam eu commodo augue. Duis in elementum felis. Fusce eget vehicula odio. Suspendisse ullamcorper mattis velit, non sodales est hendrerit in. Vivamus leo sem, tempor quis interdum et, maximus varius lacus.<br>Ut sed nibh risus. Pellentesque ullamcorper tortor pellentesque quam malesuada, euismod feugiat ligula varius. Phasellus lobortis diam ut metus tempor, sed hendrerit tellus posuere. Duis tincidunt felis in diam fermentum, in mattis sem rhoncus. Cras velit tellus, facilisis non elementum ut, accumsan ac dolor. Proin feugiat nunc in bibendum efficitur.
    </div>
    <div class="custom" id="target">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse gravida nisl ac velit dignissim lacinia. Etiam eu commodo augue. Duis in elementum felis. Fusce eget vehicula odio. Suspendisse ullamcorper mattis velit, non sodales est hendrerit in. Vivamus leo sem, tempor quis interdum et, maximus varius lacus.<br>Ut sed nibh risus. Pellentesque ullamcorper tortor pellentesque quam malesuada, euismod feugiat ligula varius. Phasellus lobortis diam ut metus tempor, sed hendrerit tellus posuere. Duis tincidunt felis in diam fermentum, in mattis sem rhoncus. Cras velit tellus, facilisis non elementum ut, accumsan ac dolor. Proin feugiat nunc in bibendum efficitur.
    </div>
  </div>

  <h2>Reference (no font-face descriptors)</h2>
  <div class="text-container">
    <div class="reference">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse gravida nisl ac velit dignissim lacinia. Etiam eu commodo augue. Duis in elementum felis. Fusce eget vehicula odio. Suspendisse ullamcorper mattis velit, non sodales est hendrerit in. Vivamus leo sem, tempor quis interdum et, maximus varius lacus.<br>Ut sed nibh risus. Pellentesque ullamcorper tortor pellentesque quam malesuada, euismod feugiat ligula varius. Phasellus lobortis diam ut metus tempor, sed hendrerit tellus posuere. Duis tincidunt felis in diam fermentum, in mattis sem rhoncus. Cras velit tellus, facilisis non elementum ut, accumsan ac dolor. Proin feugiat nunc in bibendum efficitur.
    </div>
    <div class="custom">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse gravida nisl ac velit dignissim lacinia. Etiam eu commodo augue. Duis in elementum felis. Fusce eget vehicula odio. Suspendisse ullamcorper mattis velit, non sodales est hendrerit in. Vivamus leo sem, tempor quis interdum et, maximus varius lacus.<br>Ut sed nibh risus. Pellentesque ullamcorper tortor pellentesque quam malesuada, euismod feugiat ligula varius. Phasellus lobortis diam ut metus tempor, sed hendrerit tellus posuere. Duis tincidunt felis in diam fermentum, in mattis sem rhoncus. Cras velit tellus, facilisis non elementum ut, accumsan ac dolor. Proin feugiat nunc in bibendum efficitur.
    </div>
  </div>

</div>
<p class="footnote">Made with ☕️ by <a href="https://twitter.com/simonhearne">@SimonHearne</a></p>
              
            
!

CSS

              
                body {
  width: 90%;
  max-width: 800px;
  margin: 4em auto;
  box-sizing: border-box;
  font-family: sans-serif;
}
.cssbox {
  display: block;
  white-space: pre-wrap;
  font-family: monospace;
  background: #eeee;
}
.text-container {
  position: relative;
  height: 10em;
}
.hidden {
  opacity: 0;
}
.fallback {
  position: absolute;
  font-family: fallback-font;
  border: 1px solid #0008;
}
.reference {
  position: absolute;
  font-family: Arial;
  border: 1px solid #0008;
}
.custom {
  position: absolute;
  font-family: custom-font;
  color:red;
  border: 1px solid #f008;
}
.warning {
  width: 100%;
  color: white;
  background-color: red;
  padding: 1px 8px;
}
.footnote {
  width: 100%;
  text-align: center;
}
              
            
!

JS

              
                var interval = null;

document.getElementById("flashToggle").addEventListener("change",(check) => {
  let toggling = check.target.checked
  if (toggling) {
    document.getElementById("target").classList.add("hidden");
    interval = window.setInterval(
        () => {
          document.getElementById("reference").classList.toggle("hidden")
          document.getElementById("target").classList.toggle("hidden")},
        1000)
  } else {
    clearInterval(interval);
    document.getElementById("target").classList.remove("hidden")
    document.getElementById("reference").classList.remove("hidden")
  }
})
              
            
!
999px

Console