Book a call Free rebuild

HEX Code

March 22, 2023 Updated November 16, 2026 2 min read

Design glossaryA HEX code is a six-digit hexadecimal value, such as #284282, that defines a color by its red, green, and blue parts.

A HEX code is the most common way to write a color on the web. It is a hash sign followed by six characters, such as #284282, and it is simply an RGB color written in hexadecimal (base 16) instead of ordinary numbers. Hexadecimal counts from 0 to 9 and then A to F, so two characters can express any value from 00 (0) to FF (255).

How to read a HEX code

The six characters split into three pairs: red, then green, then blue.

  • #FF0000 is full red with no green or blue: pure red.
  • #000000 is no light at all, so black, and #FFFFFF is every channel at full, so white.
  • Equal pairs, such as #808080, always give a neutral gray.
  • #284282 is red 40, green 66, and blue 130: a deep blue. In CSS, rgb(40 66 130) is exactly the same color.

With 256 values per channel, HEX codes can describe 16,777,216 colors. Letters are case-insensitive, so #ff0000 and #FF0000 are identical.

Short and long forms

  • Three digits: #F00 is shorthand for #FF0000. It works only when each pair repeats a character.
  • Eight digits: a fourth pair adds transparency (alpha). #28428280 is the same blue at about 50 percent opacity. There is a four-digit shorthand as well.

HEX, RGB, and HSL

HEX, rgb(), and hsl() all describe the same colors; they are different notations, not different palettes. HEX is compact and easy to copy between design tools, brand guidelines, and code, which is why it is everywhere. HSL is easier to adjust by hand: to make a lighter tint of a brand color, you raise its lightness rather than recalculating three hex pairs. Newer CSS color functions, such as oklch() and color-mix(), add more options, but HEX remains the common currency.

HEX codes in WordPress

The color pickers in the block editor, the Customizer, and most plugins accept and display HEX codes. In a block theme, the site palette lives in theme.json, where each color has a name, a slug, and usually a HEX value. WordPress turns each one into a CSS custom property, such as --wp--preset--color--primary, so changing a HEX value in one place updates it across the site. That beats typing the same code into dozens of blocks.

A HEX code says nothing about whether text is readable. Check every text and background pair for contrast, and keep the official HEX values in your brand guide so they do not drift from page to page.

Source: MDN, <hex-color>.

WP Services

WordPress services at revolutionary pricing.

Productized WordPress services, from builds to care, delivered by Seahawk and tracked in one app. For the WordPress lovers.