5.4 · Logic in CSS
Read HTML attributes as values: typed attr()
Turn HTML attributes into real lengths, colors and numbers.
attr() used to work only in content, and
only as a string. Now it works in any property and can parse a type:
attr(data-color type(<color>)) or, with a unit,
attr(data-value %).
The second argument is a fallback. Your HTML can carry data, such as a value or a color, and CSS turns it into layout without inline styles or JavaScript.
<li style="--value: 72%; --color: tomato">
/* or JS copying data-* into styles */
li.style.setProperty('--value', …)
li::before {
inline-size: attr(data-value %, 0%);
background: attr(data-color type(<color>), gray);
}