Browser support is 95%+.
hsl syntax
:root {
--accent-primary: hsl(0 80% 50% / 25%);
}
Change color
.darkened {
color: hsl(from var(--accent-primary) h s calc(l - 15));
}
Change color and opacity
.lightened {
color: hsl(from var(--accent-primary) h s calc(l + 15) / 0.1);
}
⚠️ Attention:
s
andl
are percents in hsl syntax, but in thehsl()
function withcalc()
they are used as absolute values - without%
sign.
Source: MDN.
Top comments (0)