<main id="main">
  <div class="hsl-container">
    <p id="hsl-display">
      hsl(<span id="h-value">0</span>deg, <span id="s-value">50</span>%, <span id="l-value">50</span>%)
    </p>
    <div class="hsl-selector">
      <div class="input-container">
        <label for="h-range">Hue:</label>
        0<input type="range" id="h-range" value="0" min="0" max="360" step="1">360
      </div>
      <div class="input-container">
        <label for="s-range">Saturation:</label>
        0<input type="range" id="s-range" value="50" min="0" max="100" step="1">100
      </div>
      <div class="input-container">
        <label for="l-range">Lightness:</label>
        0<input type="range" id="l-range" value="50" min="0" max="100" step="1">100
      </div>
    </div>
  </div>
</main>

<footer>
  <p>
    Pen by <a href="https://www.jemimaabu.com" target="_blank">Jemima Abu</a><span style="color: #D11E15"> &#9829;</span>
  </p>
</footer>
@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
}

main {
  min-height: 100vh;
  padding: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.hsl-container {
  width: 70%;
  min-width: 350px;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 3rem;
  border-radius: 1rem;
  background-color: #eaeaea90;
  box-shadow: 0 0 5px 0 #eaeaea90;
}

.hsl-selector {
  width: 100%;
}

#hsl-display {
  background-color: rgba(0,0,0,0.1);
  width: 100%;
  padding: 1.5rem;
  border-radius: 1rem;
  text-align: center;
  box-sizing: border-box;
  
}

.input-container {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  width: 100%;
}

label {
  display: inline-block;
  width: 8rem;
  margin-right: 0.5rem;
}

input[type="range"] {
  width: 100%;
}

button {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  opacity: 0.75;
  cursor: pointer;
}

button:hover {
  opacity: 1;
}

footer {
  text-align: center;
  padding: 0.5rem 0;
  background-color: #eaeaea90;
}

footer p {
  font-size: 0.75rem;
  margin: 0.25rem 0;
  color: #221133;
}

footer a {
  text-decoration: none;
  color: inherit;
}
const hVal = document.getElementById("h-value");
const sVal = document.getElementById("s-value");
const lVal = document.getElementById("l-value");
const hRange = document.getElementById("h-range");
const sRange = document.getElementById("s-range");
const lRange = document.getElementById("l-range");
const background = document.getElementById("hsl-display");

const setBackground = () => {
  const h = hRange.value;
  const s = sRange.value;
  const l = lRange.value;

  background.style.backgroundColor = `hsl(${h}deg, ${s}%, ${l}%)`;
  background.style.color = `hsl(${h}deg, 100%, ${l <= 50 ? 100 : 0}%)`;
};

setBackground();

const updateValue = (val, range) => {
  val.innerText = range.value;
  setBackground();
};

hRange.addEventListener(
  "input",
  () => {
    updateValue(hVal, hRange);
  },
  false
);

sRange.addEventListener(
  "input",
  () => {
    updateValue(sVal, sRange);
  },
  false
);

lRange.addEventListener(
  "input",
  () => {
    updateValue(lVal, lRange);
  },
  false
);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.