Is Hue Always a Whole Number?

Must I always express hue of the hsla property as a whole number, or can I use decimals as well to find greater variations in color when styling?

To my knowledge it is standard to use integer values, meaning if you use a float it is up the browser in question how it chooses to render it, if it renders at all.

If you don’t specify a unit for the hue value when using hsl()/hsla(), it assumes you’re using degrees.

Whilst you certainly can provide a non-integer value, e.g. hsl(240.4, 100%, 50%), whether there’d be a discernable difference between 240.4 and either 240 or 241 is a separate question. One presumes there’d be little difference.

(If you were specifying a hue value using radians, then decimal differences would be more noticeable…)

1 Like