<div class="container">
  <div class="counter-reset">
    <h1 data-element="h1">Counter-increment</h1>
    <p data-element="p">The counter-reset CSS property resets a CSS counter to a given value.</p>
    <aside data-element="aside">To change the value of an existing counter use counter-set, or counter-increment.</aside>
    <p data-element="p">The counter-reset CSS property resets a CSS counter to a given value.</p>
    <section data-element="section">To change the value of an existing counter use counter-set, or counter-increment.</section>
  </div>
</div>

<div class="form">
  <label for="counter-reset">counter-reset(&lt;integer&gt; = n = <span id="counter-reset-n">0</span>):</label>
  <input type="range" name="n" value="0" id="counter-reset" min="-5" max="5" step="1" />

  <label for="counter-increment">counter-increment(&lt;integer&gt; = m = <span id="counter-increment-m">1</span>):</label>
  <input type="range" name="m" value="1" id="counter-increment" min="-5" max="5" step="1" />
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");

* {
  box-sizing: border-box;
}

body {
  inline-size: 100vw;
  min-block-size: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  /*   align-items: center; */
  gap: 10px;
  font-family: "Exo", Arial, sans-serif;
  background-color: #f7f7f7;
  line-height: 2;
  padding: 20px;
}

.container {
  padding: 10px 20px;
  background: #fff;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
  min-width: 50vw;
  border-radius: 5px;
  position: relative;
  width: 80%;
  max-width: 60vw;
  flex: 1;
}

.counter-reset > * {
  margin: 1rem 0;
}

.counter-reset > * {
  display: flex;
  align-items: center;
}

section {
  border: 4px solid #ffcc00;
  box-shadow: 0 0 2px rgb(0 0 0 / 0.85), inset 2px 2px 2px rgb(0 0 0 / 0.35);
  padding: 10px;
  border-radius: 5px;
}

aside {
  border: 4px solid #5ac8fa;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 0 2px rgb(0 0 0 / 0.85), inset 2px 2px 2px rgb(0 0 0 / 0.35);
}

.counter-reset *::before {
  display: inline-flex;
  color: #fff;
  background-color: #f36;
  padding: 10px;
  line-height: 1;
  font-size: 2rem;
  margin-right: 20px;
  aspect-ratio: 1 / 1;
  justify-content: center;
  align-items: center;
  clip-path: polygon(
    0% 0%,
    89% 0,
    89% 40%,
    100% 50%,
    89% 61%,
    88% 100%,
    0 100%
  );
  border-radius: 50%;
}

.counter-reset *::after {
  content: "(" attr(data-element) "  Element)";
  font-size: 85%;
  line-height: 1;
  color: #5c2;
  margin-left: 5px;
}

.form {
  background: rgb(0 0 0 / 0.8);
  color: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-shadow: 1px 1px 0 rgb(255 125 125 / 0.8);
}

label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.counter-reset {
  counter-reset: counter-name var(--n, 0);
}

.counter-reset p {
  counter-increment: counter-name var(--m, 1);
}

.counter-reset p::before {
  content: counter(counter-name);
}
const rootElement = document.documentElement;
const inputs = document.querySelectorAll('input[type="range"]');

inputs.forEach((input) => {
  input.addEventListener("change", (etv) => {
    rootElement.style.setProperty(`--${etv.target.name}`, etv.target.value);
    document.getElementById(`${etv.target.id}-${etv.target.name}`).textContent =
      etv.target.value;
  });
});
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.