Pen Settings



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


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


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.


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.


  CSS level 4 color blend adjuster just with custom properties and calc()

  <div class="fg">Foreground</div>
  <div class="bg">Background</div>
  <div class="blended">Foreground blended with background by <em>blend percentage</em> in the HSL space</div>

  <label><strong>Blend amount</strong></label><input type="range" name="--blend-amount" value="50"/><code></code>
  <label>Background hue</label><input type="range" name="--bg-h" value="180" min="0" max="360"/><code></code>
  <label>Background saturation</label><input type="range" name="--bg-s" value="100"/><code></code>
  <label>Background lightness</label><input type="range" name="--bg-l" value="50"/><code></code>
  <label>Foreground hue</label><input type="range" name="--fg-h" value="240" min="0" max="360"/><code></code>
  <label>Foreground saturation</label><input type="range" name="--fg-s" value="100"/><code></code>
  <label>Foreground lightness</label><input type="range" name="--fg-l" value="50"/><code></code>


  The CSS level 4 blend adjuster mimicked with just custom properties and calc().
  While it's pretty straightforward to mimick the hue, saturation and
  lightness adjusters, blend requires a bit more math.
  Results might not be 100% in line with the spec, but are very much usable IMHO.
  Syntax of course is even more bloated than for the simple adjusters mentioned above.
body {
  /* Actual values set from JS */
  --bg-h: 0; --bg-s: 0; --bg-l: 0; /* Background hue, saturation, lightness. */
  --fg-h: 0; --fg-s: 0; --fg-l: 0; /* Foreground hue, saturation, lightness. */
  /* The percentage for the blend() adjuster (just unit-less in this case),
     see */
  --blend-amount: 0;
  /* If you see a pink blend result, you might have a syntax error somwehere below this. */
  --blend-result: pink;
  /* The result of blending foreground with background in the HSL space by --blend-amount: */
  --blend-result: hsl(
      (var(--fg-h) * ((100 - var(--blend-amount)) * 0.01)) +
      (var(--bg-h) * (var(--blend-amount) * 0.01))
      (var(--fg-s) * ((100 - var(--blend-amount)) * 0.01)) +
      (var(--bg-s) * (var(--blend-amount) * 0.01))
    ) * 1%),
      (var(--fg-l) * ((100 - var(--blend-amount)) * 0.01)) +
      (var(--bg-l) * (var(--blend-amount) * 0.01))
    ) * 1%)

/* A few demo styles. */
h1 {
  /* This is how colors need to be specified.
     Conversion of saturation and lightness to percentage done here to enable prior calculations. */
  background-color: hsl(var(--bg-h), calc(var(--bg-s) * 1%), calc(var(--bg-l) * 1%));
  color: var(--blend-result);

  font-weight: bold;
  font-size: 26px;
  padding: 1em;
  position: relative;
body {
  font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
body > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: left;
  margin: 0 -.5em;
div > div {
  color: white;
  text-shadow: 1px 1px 1px black;
  flex: max-content 0 0;
  padding: 3em;
  margin: .5em;
/* div + div { margin-left: 2em } */
.bg { background-color: hsl(var(--bg-h), calc(var(--bg-s) * 1%), calc(var(--bg-l) * 1%)) }
.fg { background-color: hsl(var(--fg-h), calc(var(--fg-s) * 1%), calc(var(--fg-l) * 1%)) }
.blended { background-color: var(--blend-result) }
form {
  display: grid;
  grid-template-columns: minmax(min-content, max-content) max-content max-content;
  grid-gap: .5em;
  align-items: center;
  margin-top: 1em;
code { text-align: right }


                const updateStyle = element =>, element.value) || (element.nextElementSibling.innerText = element.value)
Array.from(document.querySelectorAll('input')).forEach(input => updateStyle(input))
document.addEventListener('input', ({ target }) => requestAnimationFrame(() => updateStyle(target)))