<h1>Change underline offset using the slider</h1>
<input type="range" min="-3" max="3" step="0.1" value="0">

<output class="code-container"><span class="token-selector">h1</span> { <span class="token-property">text-underline-offset</span>: <span class="token-function">auto</span> }</output>
body {
  padding: 0 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

h1 {
  display: block;
  font-size: 2rem;
  color: hsl(207, 90%, 54%);
  text-decoration: underline;
}

@supports not (text-underline-offset: auto) {
  h1::after {    
    content: "Your browser doesn't support this property";
    display: block;
    color: #e43;
    margin-top: 1rem;
    font-weight: bold;
    text-decoration: unset;
    font-size: 12px;
  }
}

input {
  width: 12.5rem;
  margin: 7rem auto 2rem;
}

output {
  display: block;
}

.code-container {
  width: 20.3rem;
  max-width: 100%;
  overflow-x: auto;
  text-align: center;
  background-color: #272822;
  padding: 1.5rem;
  border-radius: 3px;
  color: #F8F8F2;
  text-shadow: 0 1px rgba(0, 0, 0, 0.3);
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
}

.token-property {
  color: #F92672;
}

.token-function {
  color: #E6DB74;
  display: inline-block;  
  width: 3.75rem;
 
}

.token-selector {
  color: #a6e22e;
}
var text = document.querySelector('h1'),
    slider = document.querySelector('input');

slider.addEventListener('input', function () {
  text.style.textUnderlineOffset = this.value + 'em';
  document.querySelector('.token-function').textContent = this.value + 'em';
}, false);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.