HEX, RGB and HSL color codes explained

Published by InstantToolDeck · Updated November 2026

Screens make every color from three lights: red, green and blue. Different notations describe the same mix in different ways. This guide explains the common ones and shows how to convert between them with the Color Converter.

RGB

RGB gives the strength of red, green and blue from 0 (none) to 255 (full). rgb(26, 115, 232) is a medium blue. rgb(0, 0, 0) is black and rgb(255, 255, 255) is white. CSS also allows percentages and a space-separated form: rgb(10% 45% 91%).

HEX

HEX is RGB written in base 16 with two digits per channel: #1a73e8 means red 1A (26), green 73 (115) and blue E8 (232). Three digits are shorthand where each digit is doubled, so #fc0 is #ffcc00. Four and eight digits add an alpha (transparency) channel: #1a73e880 is the same blue at about 50 percent opacity. You can convert with the HEX to RGB and RGB to HEX pages; see binary, decimal and hexadecimal explained for how hex works.

HSL

HSL describes color the way people think about it: hue is the position on the color wheel in degrees (0 red, 120 green, 240 blue), saturation is how vivid it is, and lightness runs from black (0 percent) through the pure color (50 percent) to white (100 percent). To make a darker shade of a brand color, lower the lightness and leave the hue alone. That is much easier than editing RGB numbers. Try HEX to HSL and HSL to HEX.

HSV and CMYK

HSV (or HSB) uses value instead of lightness and appears in many color pickers. CMYK (cyan, magenta, yellow, black) is the model used in printing. The CMYK shown by an online converter is a mathematical conversion; real print results depend on the printer, ink and paper profile, so use it as a starting point.

Named colors

CSS defines 148 color names such as coral, navy and rebeccapurple. Look up any of them with color name to HEX.

Contrast and accessibility

Text must stand out from its background. The Web Content Accessibility Guidelines measure this as a contrast ratio from 1:1 (no difference) to 21:1 (black on white). Level AA requires at least 4.5:1 for normal text and 3:1 for large text; level AAA asks for 7:1. White text on #1a73e8 scores about 4.5:1, which only just passes AA, while white on a light yellow fails badly. The Color Converter shows the ratio against both white and black so you can choose the readable one.

Practical tips

  • Keep a small palette: one brand color, a few tints and shades, and neutral grays.
  • Do not rely on color alone to show meaning; add text or an icon for people with color blindness.
  • Test on a dark background too if your site supports dark mode.
  • Use alpha sparingly; transparent text over images is hard to read.

Frequently asked questions

How do I convert HEX to RGB?

Split the code into three pairs and convert each from hex to decimal. #1a73e8 becomes 26, 115, 232.

What is the difference between HSL and HSV?

Both use hue and saturation. HSL uses lightness where 100 percent is white; HSV uses value where 100 percent is the brightest version of the color.

What contrast ratio do I need?

At least 4.5:1 for normal text and 3:1 for large text to meet WCAG AA.

Can HEX codes be transparent?

Yes. Eight-digit HEX such as #ff000080 has an alpha channel in the last two digits.

← All guides