Spec-Zone.ru › CSS

`<hue>` CSS type

Baseline Widely available

This feature is well established and works across many devices and browser versions. It's been available across browsers since January 2020.

The <hue> CSS data type represents the hue angle of a color. It is used in the color functions that accept hue expressed as a single value, specifically hsl(), hwb(), lch(), and oklch() functional notations.

Syntax

A <hue> can be either an <angle> or a <number>.

Values

<angle>
An angle expressed in degrees, gradians, radians, or turns using the deg, grad, rad, or turn, respectively.
<number>
A real number, representing degrees of the hue angle.

As an <angle> is periodic, <hue> is normalized to the range [0deg, 360deg). It implicitly wraps around such that 480deg is the same as 120deg, -120deg is the same as 240deg, -1turn is the same as 1turn, and so on.

Description

An sRGB color wheel

The color wheel above shows hues at all angles in the sRGB color space. In particular, red is at 0deg, yellow is at 60deg, lime is at 120deg, cyan is at 180deg, blue is at 240deg, and magenta is at 300deg.

The angles corresponding to particular hues differ depending on the color space. For example, the hue angle of sRGB green is 120deg in the sRGB color space, but 134.39deg in the CIELAB color space.

The following table lists typical colors at various angles in the sRGB (used by hsl() and hwb()), CIELAB (used by lch()), and Oklab (used by oklch()) color spaces:

0° 60° 120° 180° 240° 300°
sRGB
CIELAB
Oklab

Interpolation of <hue> values

<hue> values are interpolated as <angle> values, and the default interpolation algorithm is shorter. In some color-related CSS functions, this can be overridden by the <hue-interpolation-method> component.

Formal syntax

<hue> = 
  <number> |
  <angle>

Examples

Changing the hue of a color using a slider

The following example shows the effect of changing the hue value of the hsl() functional notation on a color.

HTML

<input type="range" min="0" max="360" value="0" id="hue-slider" />
<p>Hue: <span id="hue-value">0deg</span></p>
<div id="box"></div>

CSS

div {
  width: 100px;
  height: 100px;
  margin: 10px;
  border: 1px solid black;
}
p {
  font-family: sans-serif;
}
span {
  font-family: monospace;
  background: rgb(0 0 0 / 10%);
  padding: 3px;
}
#hue-slider {
  width: 90%;
}
#box {
  background-color: hsl(0 100% 50%);
}

JavaScript

const hue = document.querySelector("#hue-slider");
const box = document.querySelector("#box");
hue.addEventListener("input", () => {
  box.style.backgroundColor = `hsl(${hue.value} 100% 50%)`;
  document.querySelector("#hue-value").textContent = `${hue.value}deg`;
});

Result

Approximating red hues in different color spaces

The following example shows a similar red color in different color spaces. The values in the lch() and oklch() functions are rounded for readability.

HTML

<div data-color="hsl-red">hsl()</div>
<div data-color="hwb-red">hwb()</div>
<div data-color="lch-red">lch()</div>
<div data-color="oklch-red">oklch()</div>

CSS

[data-color="hsl-red"] {
  /* hsl(<hue> <saturation> <lightness>) */
  background-color: hsl(0 100% 50%);
}
[data-color="hwb-red"] {
  /* hwb(<hue> <whiteness> <blackness>) */
  background-color: hwb(0 0% 0%);
}
[data-color="lch-red"] {
  /* lch(<lightness> <chroma> <hue>) */
  background-color: lch(50 150 40);
}
[data-color="oklch-red"] {
  /* oklch(<lightness> <chroma> <hue>) */
  background-color: oklch(0.6 0.4 20);
}
div {
  font-family: monospace;
  width: 100px;
  height: 100px;
  margin: 10px;
  border: 1px solid black;
  display: inline-block;
}

Result

Specifications

Specification
CSS Color Module Level 4
# typedef-hue

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
hsl
1
12
1
9.5
3.1
18
4
10.1
2
1.0
4.4
2
alpha_parameter
65
79
52
52
12.1
65
52
47
12.2
9.0
65
12.2
mixed_type_parameters
121
121
122
107
18
121
122
81
18
25.0
121
18
relative_syntax
125
119–125s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
125
119–125s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
128
111
105–111s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for s and l).
125
119–125s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
128
83
79–83s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for s and l).
27.0
25.0–27.0s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
125
119–125s and l channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require s and l values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for s and l).
space_separated_parameters
65
79
52
52
12.1
65
52
47
12.2
9.0
65
12.2
hwb
101
101
96
87
15
101
96
70
15
19.0
101
15
mixed_type_parameters
121
121
122
107
18
121
122
81
18
25.0
121
18
relative_syntax
125
119–125w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
125
119–125w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
128
111
105–111w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for w and b).
125
119–125w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
128
83
79–83w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for w and b).
27.0
25.0–27.0w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
125
119–125w and b channel values incorrectly resolve to numbers between 0-1 rather than 0-100. As a result, channel value calculations require w and b values to be specified as decimal percentage equivalents (e.g. 0.2 for 20%). See bug 330096624.
18
16.4–18Implementation based on older spec version. As a result, calculations with channel values do not work correctly, requiring values to be specified with units (deg for h, % for w and b).
lch
111
111
113
97
15
111
113
75
15
22.0
111
15
mixed_type_parameters
116
116
113
102
16.2
116
113
78
16.2
24.0
116
16.2
relative_syntax
119
119
128
105
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).
119
128
79
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).
25.0
119
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).
oklch
111
111
113
97
15.4
111
113
75
15.4
22.0
111
15.4
mixed_type_parameters
116
116
113
102
16.2
116
113
78
16.2
24.0
116
16.2
relative_syntax
122
119–122l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
122
119–122l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
128
108
105–108l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).
122
119–122l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
128
81
79–81l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).
26.0
25.0–26.0l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
122
119–122l channel values incorrectly resolve to numbers between 0-100 rather than 0-1. As a result, channel value calculations require l values to be specified as percentage numbers without units (e.g. 20 for 0.2). See bug 40940488.
18
16.4–18Implementation based on older spec version. As a result, calculations with h channel values do not work correctly, requiring values to be specified with units (deg).

See also

  • color
  • <hue-interpolation-method>

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/hue

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API