css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  <label for="h">Hue<span>(0 - 360)</span></label>
  <input type="number" id="h" value="0" />
  <label for="h">Saturation<span>(0 - 100%)</span></label>
  <input type="number" id="s" value="50" />
  <label for="h">Lightness<span>(0 - 100%)</span></label>
  <input type="number" id="l" value="50" />

<footer>hsl(<span id="hdisplay"></span>, <span id="sdisplay"></span>, <span id="ldisplay"></span>)
              :root {
  --h: 0;
  --s: 50;
  --l: 50;

body {
  background: hsl(var(--h), calc(var(--s) * 1%), calc(var(--l) * 1%));

#hdisplay::after {
  counter-reset: hcount var(--h);
  content: counter(hcount);
#sdisplay::after {
  counter-reset: scount var(--s);
  content: counter(scount) '%';
#ldisplay::after {
  counter-reset: lcount var(--l);
  content: counter(lcount) '%';

/* Structure */
body {
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  font-family: -apple-system, system-ui;
  font-size: 82.5%;

div {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: hsla(0, 0%, 0%, .6);
  color: hsl(0, 100%, 100%);
  padding: 1rem .5rem 3rem;
input {
  height: 3rem;
  font-size: 2rem;
  width: 99%;
  text-align: center;
  position: relative;
  display: block;
  appearance: none;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: hsl(0, 100%, 100%);
  border-bottom: .1rem solid currentColor; 
label {
  display: block;
  text-align: center;
label span {
  display: block;
  padding: .25rem 0;

footer {
  position: absolute;
  color: hsl(0, 0%, 100%);
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 1rem;
              //match the initial values of the CSS Variables
var hsl = {
  h: 0,
  s: 50,
  l: 50

var hinput = document.getElementById('h');
var sinput = document.getElementById('s');
var linput = document.getElementById('l');

Array.from(document.querySelectorAll('input')).forEach(function(item) {
  item.addEventListener('input', onNewValue);

function onNewValue(element) {
  if (element.tagName !== 'INPUT') {
    element = element.currentTarget;
  //input for h, s, or l?
  var which = element.id;
  //current number value
  hsl[which] = element.value;
  //update CSS Variable value, which in turn updates the background color as well as the displayed hsl value at the bottom of the screen
  document.documentElement.style.setProperty('--' + which, hsl[which]);

// When focused on Body
// Q/A to +/- Hue
// W/S to +/- Saturation
// E/D to +/- Lightness
document.body.addEventListener('keydown', function(e) {
  if (e.key === 'Q' || e.key === 'q') {
    updateValue(hinput, hsl.h);
  } else if (e.key === 'A' || e.key === 'a') {
    updateValue(hinput, hsl.h);
  } else if (e.key === 'W' || e.key === 'w') {
    updateValue(sinput, hsl.s);
  } else if (e.key === 'S' || e.key === 's') {
    updateValue(sinput, hsl.s);
  } else if (e.key === 'E' || e.key === 'e') {
    updateValue(linput, hsl.l);
  } else if (e.key === 'D' || e.key === 'd') {
    updateValue(linput, hsl.l);
function updateValue(el, val) {
  el.value = val;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................