CSS and JavaScript variables

I just fount out about CSS variables and I’m just wondering how I would increase and decrease the value of them.

so I have this bar that I want to increase and decrease the value of depending on what passage I am on.

.bar {
  width: calc(var(--width, 0) * 1)
  height: 100px;
  color: black;
}

The Making Custom Properties (CSS Variables) More Dynamic article on the CSS-Tricks website discusses ways to alter the assigned value of such a property/variable.

1 Like