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 class="wrapper">
  <div class="example">
    <h1>Aliquam gravida</h1>
    
    <p>
      Fusce semper id arcu id porttitor. Etiam sed quam vel ante laoreet varius at sed purus. Morbi commodo est nec felis tempor sollicitudin. Aliquam gravida nunc quis vestibulum volutpat. Sed quis dui sodales, congue risus vel, blandit lectus. In porta odio purus, id posuere tortor viverra vel. Etiam nunc quam, rutrum non diam eu, cursus tincidunt lorem.
    </p>
    
  </div>
  
  <div class="range">
    <span class="range__min"></span>
    <span class="range__container"></span>
    <span class="range__max"></span>
  </div>
</div>
              
            
!

CSS

              
                @font-face {
  font-family: AmstelvarVF;
  font-display: swap;
  src: url(https://yoksel.github.io/variable-fonts/assets/fonts/AmstelvarAlpha/AmstelvarAlpha-VF.ttf) format("truetype");
}

HTML, BODY {
  display: flex;
  min-height: 100%;
  width: 100%;
}

BODY {
  display: flex;
  justify-content: center;
  align-items: center;
  font: 16px/1.4 Trebuchet MS, Arial, sans-serif;
}
.wrapper {
  max-width: 500px;
  margin: 0 30px;
  text-align: center;
}

.example {
  font-family: AmstelvarVF;
  
  H1 {
    margin: 0 0 .25em;
    font-size: 50px;  
  }
  
  p {
    max-height: 110px;
    overflow: hidden;
  }
}

.range {
  margin-top: 32px;
  padding: 16px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #ececec;
  border-radius: 5px;
}

.range__container {
  margin: 0 10px;
  display: flex;
  align-items: center;
}

.range__input {
  cursor: pointer;
}
              
            
!

JS

              
                const config = {
  min: 10,
  max: 72,
  name: 'opsz',
  fullName: 'Optical size',
  step: 1
};

const wrapper = document.querySelector('.wrapper');
const rangeContainer = document.querySelector('.range__container');
const rangeMin = document.querySelector('.range__min');
const rangeMax = document.querySelector('.range__max');
const example = document.querySelector('.example');

const rangeInput = document.createElement('input');
rangeInput.classList.add('range__input');
rangeInput.type = 'range';
rangeInput.min = config.min;
rangeInput.max = config.max;
rangeInput.step = config.step;
rangeInput.value = rangeInput.min;

setVariation(rangeInput.value);

rangeMin.innerHTML = rangeInput.min;
rangeMax.innerHTML = rangeInput.max;
rangeContainer.appendChild(rangeInput);

rangeInput.addEventListener('input', function() {
  setVariation(this.value);
});

function setVariation(val) {
  example.style['font-variation-settings'] = `"wdth" 400, "wght" 70, "${config.name}" ${val}`;
}
              
            
!
999px

Console