Datatypes › Common › color

HSL color

ID hslcolor

Pattern of colorNot PIIcategoricalDraft

This record is a draft: it has not been reviewed yet and may be incomplete or wrong. Do not rely on it for compliance decisions. Help improve it (see CONTRIBUTING.md).

Color written as hue, saturation and lightness: a hue angle from 0 to 360 degrees and two percentages from 0% to 100%, separated by commas, either bare (0, 100%, 50%) or in the CSS functional notation hsl(0, 100%, 50%). The regexp accepts whole and decimal numbers (hsl(51.4285714286,50%,50%), as the color scales of Plotly charts write them), without the deg unit, an alpha channel or the space-separated syntax of CSS Color Level 4.

Pattern of
Color color
Categories
Common
Countries
Global (not tied to a country)
Languages
Common to most languages
AutoType benchmark
hsl
Quality
100/100
Metacrafter rules
1 rule (0 by field name, 1 by value)
Supported by tools
Auto-Type, metacrafter, validator.js

Regular expression

^(?:hsl\(\s*(?:360(?:\.0+)?|(?:3[0-5]\d|[12]\d\d|[1-9]?\d)(?:\.\d+)?)\s*,\s*(?:100(?:\.0+)?|[1-9]?\d(?:\.\d+)?)%\s*,\s*(?:100(?:\.0+)?|[1-9]?\d(?:\.\d+)?)%\s*\)|(?:360(?:\.0+)?|(?:3[0-5]\d|[12]\d\d|[1-9]?\d)(?:\.\d+)?)\s*,\s*(?:100(?:\.0+)?|[1-9]?\d(?:\.\d+)?)%\s*,\s*(?:100(?:\.0+)?|[1-9]?\d(?:\.\d+)?)%)$

Python re syntax.

Test a value

Examples

ValueDescription
hsl(0, 100%, 50%) Pure red
120, 100%, 25% Dark green
0, 0%, 100% White
hsl(51.4285714286,50%,50%) decimal hue, as Plotly color scales write it
361, 50%, 50% invalid Hue above 360
120, 100, 25 invalid Saturation and lightness without %

Translations

LanguageNameDescription
RussianЦвет HSLЦвет, записанный тоном (0–360°), насыщенностью и светлотой в процентах.

Sources

Use this record