What is a Hex Code? | Glossary

Glossary

What is a Hex Code?

A hex code is a six-character color value like #1A73E8 that tells a screen exactly how much red, green and blue to mix. It is the standard color format in CSS.

A hex code is a way of writing an exact colour as a hash sign followed by six characters, such as #FFFFFF for white or #000000 for black. It is the most common colour format in web design, so when a designer or brand guide says "our blue is #1A73E8", any website or design tool can reproduce precisely that shade.

How to read the six characters

"Hex" is short for hexadecimal, a counting system with sixteen digits: 0 to 9, then A to F. The six characters are three pairs, one each for red, green and blue: #RRGGBB. Each pair runs from 00 (none of that colour) to FF (the maximum, equal to 255 in normal numbers). So a hex code is just a compact way to write an RGB value.

  • #FF0000 is full red, no green, no blue: pure red.
  • #808080 is equal medium amounts of all three: grey.
  • #1A73E8 is a little red, some green and a lot of blue.

With 256 levels per channel, six-digit hex can describe 16,777,216 colours. Letters are not case-sensitive, so #1a73e8 is the same colour.

Short and long variants

CSS accepts a three-digit shorthand where each digit is doubled: #F60 means #FF6600. It also accepts eight digits, where the last pair is transparency: #00000080 is black at about 50 percent opacity.

Example: matching a shop sign

A florist wants the website to match her painted sign. She photographs it, uses an eyedropper in a design tool to sample the colour, and gets #2E5E4E. That code goes into the site's CSS, her email signature and the print shop's order, so the green is consistent everywhere. Printers will convert it to CMYK, so a printed proof is still worth checking.

Where hex codes trip people up

  • Confusing O with 0. The letter O is not a hex digit; #0O0000 is invalid.
  • Dropping the hash in CSS. color: 1A73E8 does nothing; it needs the # sign.
  • Sampling from a compressed image. JPEG artefacts shift colours slightly. Get the official value from the logo file or brand guide.
  • Judging contrast by eye. Run text and background hex codes through a contrast checker before publishing.

Related terms

  • RGB: the colour model a hex code encodes.
  • Color palette: a set of colours usually listed as hex codes.
  • CSS: the language where hex codes are applied.
  • Brand guidelines: where official hex values are recorded.

Ready to put this into practice?

We.Inc lets you describe a site in chat and watch AI build it live, then refine it visually or in code.

Start Building

No credit card required

Describe your business. Get a website ready to publish.

Ready to simplify everything?

Join 15,000+ businesses that replaced their entire marketing stack with one platform.

No credit card required · Talk to sales

Product

Who It's For

Features

Resources

Company

View Sitemap