<div class="counter">
  <span class="dec" onclick="updateCounter('INC')">&#171;</span>
  <span class="value">0</span>
  <span class="inc" onclick="updateCounter('DEC')">&#187;</span>
</div>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

main {
  font-family: "Courier New", Courier, monospace;
}

.counter {
  width: max-content;
  margin: 10vh auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 16px;
}
.counter > span {
  padding: 0.5em;
}

.inc,
.dec {
  cursor: pointer;
  font-size: 3em;
  font-weight: 700;
  transform: rotate(90deg);
  color: #0b0c64;
}

.inc:hover,
.dec:hover {
  opacity: 0.8;
}

.value {
  font-size: 3em;
  min-width: 200px;
  min-height: 200px;
  background: #368bec;
  color: #fff;
  border-radius: 1em;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0.5em 0 #00000073;
}
const [inc, value, dec] = document.querySelector(".counter").children;

// Check counter exist in localStorage
// if not then initialise it to zero
if (!localStorage.counter) localStorage.counter = 0;

value.innerHTML = localStorage.counter;

const updateCounter = (action) => {
  switch (action) {
    case "INC":
      // since localStorage stores in DOMString
      // We have to convert it in number
      localStorage.counter = Number(localStorage.counter) + 1;
      break;
    case "DEC":
      localStorage.counter = Number(localStorage.counter) - 1;
      break;
  }
  value.innerHTML = localStorage.counter;
};

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.