Xerobit

Hex Color Codes: Web Safe and Named Color Chart

Look up hex color codes for any of the 148 CSS named colors or the 216 web-safe palette. This hex color chart shows each color alongside its RGB and HSL equivalents so you can copy the exact value you need. Everything runs in your browser and nothing is uploaded.

Result

  • Hex
    #663399
  • RGB
    rgb(102, 51, 153)
  • HSL
    hsl(270, 50%, 40%)
  • CSS Name
    rebeccapurple
  • Web-safe
    Yes

How to use the html color codes

  1. Type a CSS color name (like tomato) or a hex value (like #FF6347) into the search field.
  2. The tool instantly resolves the input to its matching hex color codes, RGB triplet, and HSL equivalent.
  3. Check whether the color belongs to the 216 web-safe palette or matches one of the 148 named colors.
  4. Copy the resulting hex color code directly into your CSS, HTML, or design application.

What are hex color codes?

Hex color codes represent colors in the sRGB color space using a six-digit hexadecimal number prefixed by a hash symbol. The format is #RRGGBB, where RR is red, GG is green, and BB is blue. Each pair ranges from 00 (zero intensity) to FF (full intensity, or 255 in decimal). For example, pure red is #FF0000, which translates to rgb(255, 0, 0). Because each channel has 256 possible values, the total number of colors is 256 x 256 x 256, or 16,777,216.

CSS also supports a three-digit shorthand when both digits of each channel match. #F00 expands to #FF0000, and #ABC expands to #AABBCC. This shorthand is widely used in stylesheets to save bytes.

The 216 web-safe palette

In the early days of the web, many displays could only render 256 colors. To guarantee consistent rendering across platforms, designers relied on a subset of 216 colors known as the web-safe palette. These colors use only the hex pairs 00, 33, 66, 99, CC, and FF for each channel (decimal 0, 51, 102, 153, 204, 255).

Hex stepDecimalPercentage
0000%
335120%
6610240%
9915360%
CC20480%
FF255100%

Modern screens display millions of colors, so the strict web-safe constraint is no longer necessary. However, these hex color codes remain useful for building systematic palettes, generating uniform grids, and maintaining visual consistency in data visualization. Six steps per channel yield exactly 6 x 6 x 6 = 216 combinations.

CSS named colors

The CSS Color Level 4 specification defines 148 named colors that browsers recognize directly. You can use these names in place of hex color codes or RGB functions in your stylesheets. The list includes the original 16 HTML 4.01 colors (like red, blue, green), the extended X11 color set, plus rebeccapurple (#663399), added in 2014.

Named colors are convenient for quick prototypes and readable code, but they cover only a tiny fraction of the available spectrum. For precise control, designers typically prefer hex color codes or HSL notation. Note that transparent is a valid CSS color keyword but represents fully transparent black rather than a specific hue, so it is excluded from the standard 148 named colors.

Converting between formats

Every hex color code maps directly to an RGB triplet and an HSL (Hue, Saturation, Lightness) representation. To convert a hex code like #4A90D9 to RGB, split it into pairs and convert from base 16 to base 10: 4A becomes 74, 90 becomes 144, and D9 becomes 217, giving rgb(74, 144, 217).

HSL expresses the same color as a degree on the color wheel (0 to 360), a saturation percentage, and a lightness percentage. Converting requires finding the maximum and minimum RGB channel values, computing the difference, and applying trigonometric logic to determine the hue angle. Many developers prefer HSL because adjusting lightness or saturation is more intuitive than modifying hex pairs. If you need to blend two colors together, a color mixer handles the math automatically.

Using hex color codes in CSS and HTML

Hex color codes are the most common way to define colors in frontend development. In CSS, apply them to text, backgrounds, borders, and shadows:

  • color: #333333;
  • background-color: #F5F5F5;
  • border: 1px solid #0066CC;

In HTML, inline styles accept the same syntax: <span style="color: #FF0000;">Text</span>. SVG elements also use hex values for fill and stroke attributes. When building seasonal themes, you might start with a curated autumn color palette or a spring color palette and then extract the exact hex values for your stylesheet.

Common mistakes with color values

A frequent error is using an invalid hex character. Hexadecimal only allows digits 0 through 9 and letters A through F. Typing #GG0000 will cause the browser to ignore the declaration entirely. Another issue is confusing three-digit and six-digit shorthands: #123 expands to #112233, not #123000 or #000123.

Developers also sometimes mix up RGB decimal values with hex values. Remember that rgb(255, 0, 0) is equivalent to #FF0000, not #255000. Finally, while named colors are easy to read, relying on them exclusively limits your options to just 148 choices out of over 16 million. For production interfaces, sticking to hex color codes or HSL ensures precision.

Worked examples

ExampleInputResult
Named color lookupColor name or hex code: rebeccapurpleHex: #663399; RGB: rgb(102, 51, 153); HSL: hsl(270, 50%, 40%); CSS Name: rebeccapurple; Web-safe: Yes
Six-digit hex codeColor name or hex code: #FF5733Hex: #FF5733; RGB: rgb(255, 87, 51); HSL: hsl(11, 100%, 60%); Web-safe: No
Three-digit shorthandColor name or hex code: #0AFHex: #00AAFF; RGB: rgb(0, 170, 255); HSL: hsl(200, 100%, 50%); Web-safe: No
Web-safe colorColor name or hex code: #336699Hex: #336699; RGB: rgb(51, 102, 153); HSL: hsl(210, 50%, 40%); Web-safe: Yes

FAQ

How many hex color codes exist?

There are 16,777,216 possible hex color codes in the standard 24-bit sRGB color space. This comes from 256 levels each for red, green, and blue (256 x 256 x 256).

What is the difference between 3-digit and 6-digit hex codes?

A 3-digit hex code is a shorthand where each digit is doubled. For example, #F0A expands to #FF00AA. It only works when both digits of each color channel are identical.

Are web-safe colors still necessary?

No. Modern displays support millions of colors, making the 216-color web-safe palette obsolete for general use. However, it remains a handy framework for generating evenly spaced color grids.

How many named colors does CSS support?

CSS Color Level 4 defines 148 named colors, including standard colors like red and blue, X11 colors like aliceblue, and rebeccapurple. The keyword transparent is also supported but represents fully transparent black.

Do hex color codes support transparency?

Yes, modern CSS supports 4-digit and 8-digit hex codes that include an alpha channel. For example, #FF000080 represents red at roughly 50% opacity, and #F008 is its shorthand.

Is there a hex color code for transparent?

You can use #00000000 (fully transparent black) or rely on the CSS keyword transparent. Both achieve the same visual result in modern browsers.