RGB To HSL
Reverse Conversion
How This Converter Works
Converts RGB channel values to rounded HSL hue, saturation, and lightness; optional alpha is included in the CSS-style result only when below 1.
Formula or rule
Normalize channels by 255; L=(max+min)/2. For unequal channels S=delta/(1-|2L-1|); hue follows the max-channel sector, then H, S, and L are rounded to integer degrees and percentages.
Example
- Input
- RGB 255, 0, 0
- Calculation
- Normalized channels are 1,0,0; max=1, min=0, L=0.5, S=1, hue=0°.
- Result
- hsl(0, 100%, 50%)