Skip to main content
Numverto numverto
hexadecimal web design CSS

Hexadecimal Color Codes in Web Design Complete Guide

Learn how hex color codes work in CSS and web design. Understand RGB to hex conversion, color code formats (#RGB, #RRGGBB), and a complete reference table.

Numverto Editorial Team Numverto Editorial Team 11 min read Editorial standards

[HERO IMAGE] Alt text: “Illustration of RGB color channels combining into a hexadecimal color code on a design canvas” Caption: Every hex color code is just a compact way of writing three RGB values in base-16


Table of Contents

  1. What Are Hex Color Codes?
  2. Key Concepts
  3. Common Web Colors Reference
  4. How RGB Maps to Hex
  5. Worked Conversion Examples
  6. Shorthand Notation
  7. Alpha Transparency
  8. Using Hex in CSS
  9. Hex vs RGB vs HSL
  10. Common Mistakes
  11. Tools to Find Any Hex Code
  12. Practice Questions
  13. FAQ

Introduction

Open the CSS file of almost any website and you’ll see them everywhere: short strings like #0D1B2A or #FFF tucked into background-color and color properties. These are hex color codes, and they’re the most common way colors get defined across the web used in CSS, HTML attributes, and virtually every design tool from Figma to Photoshop.

This guide breaks down exactly how hex codes work, how they map back to the RGB values you might already be familiar with, and covers the shorthand and transparency tricks that make them so convenient for developers and designers alike.

Definition

A hex color code is a six-digit (or three-digit shorthand) hexadecimal representation of a color’s Red, Green, and Blue intensity values, written as #RRGGBB, where each pair of digits ranges from 00 to FF (0–255 in decimal).

Quick Summary (TL;DR)

  • Hex codes represent color using base-16 notation: #RRGGBB, where each pair is one color channel (Red, Green, Blue).
  • Each channel ranges from 00 (no light) to FF (full intensity, equal to 255 in decimal).
  • Shorthand #RGB only works when both digits in each pair match (e.g., #F0F = #FF00FF).
  • CSS also supports 8-digit hex codes (#RRGGBBAA) where the last pair controls transparency.
  • Hex is preferred over rgb() mainly because it’s shorter and easier to copy-paste, not because it’s technically superior.

Why This Matters

If you write any CSS, work with a design tool, or build UI components, you’ll run into hex codes constantly in Figma exports, Tailwind configs, brand style guides, and browser DevTools. Understanding what those six characters actually mean (rather than just copy-pasting them) makes it much easier to tweak a color slightly, debug why something looks “off,” or convert between formats when a design tool gives you RGB but your code needs hex.

What Are Hex Color Codes?

Every color you see on a screen is built from a mix of Red, Green, and Blue light this is how monitors, phones, and displays physically work. Hex color codes are simply a compact way to write those three RGB values using hexadecimal (base-16) notation, and they’ve become the de facto standard across CSS, HTML, and design software worldwide.

Convert hex values instantly: Number System Converter — switch between decimal, hex, binary, and octal in one click.

A hex color code always starts with #, followed by 6 characters (or 3 in shorthand form), where each pair represents one color channel:

#RRGGBB
 ↑  ↑  ↑
 Red Green Blue

Each channel ranges from 00 (0 intensity) to FF (255, full intensity).

[IMAGE: RGB channels to hex code diagram] Alt text: “Diagram showing how red, green, and blue color channels combine into a six-digit hex code”

Key Concepts You Need First

TermMeaning
Hexadecimal (base-16)A number system using digits 0-9 and letters A-F to represent values 0-15
ChannelOne of the three color components — Red, Green, or Blue
IntensityHow strong that channel’s contribution is, from 0 (none) to 255 (maximum)
Shorthand hexA 3-character version used when both digits in each pair are identical
Alpha channelAn optional 4th pair controlling transparency in 8-digit hex codes

Common Web Colors Reference

ColorHex CodeRGB
Black#000000000
White#FFFFFF255255255
Red#FF000025500
Green#00800001280
Blue#0000FF00255
Yellow#FFFF002552550
Cyan#00FFFF0255255
Magenta#FF00FF2550255
Orange#FFA5002551650
Purple#8000801280128
Navy#00008000128
Teal#0080800128128
Gray#808080128128128
Silver#C0C0C0192192192

[IMAGE: Color swatch reference chart] Alt text: “Color swatch chart showing 14 common web colors with their hex codes and RGB values” (Build this one in a design tool with exact hex fills — not AI-generated — since color accuracy is critical here.)

How RGB Maps to Hexadecimal

Each RGB value (0–255 in decimal) converts to a 2-digit hex number (00–FF):

  • Decimal 0 → Hex 00 (no light)
  • Decimal 128 → Hex 80 (half intensity)
  • Decimal 255 → Hex FF (full intensity)

Conversion Examples, Step by Step

Example 1: RGB(66, 135, 245) → Hex

  • R = 66 → 66 ÷ 16 = 4 remainder 2 → 42
  • G = 135 → 135 ÷ 16 = 8 remainder 7 → 87
  • B = 245 → 245 ÷ 16 = 15 remainder 5 → F5

Result: #4287F5 (a shade commonly known as “Google Blue”)

Example 2: RGB(255, 165, 0) → Hex

  • R: 255 ÷ 16 = 15 remainder 15 → FF
  • G: 165 ÷ 16 = 10 remainder 5 → A5
  • B: 0 ÷ 16 = 0 remainder 0 → 00

Answer: #FFA500 (Orange)

Use the Hex to Decimal Converter to verify any conversion yourself.

[IMAGE: Step-by-step RGB to hex conversion flow] Alt text: “Flowchart showing the step-by-step process of converting an RGB value into a hexadecimal color code”

How to Convert RGB to Hex Manually

  1. Step 1: Take each RGB value (0–255)
  2. Step 2: Divide by 16, and note the quotient and remainder
  3. Step 3: Convert the quotient and remainder into hex digits (where 10=A, 11=B, … 15=F)
  4. Step 4: Combine as # + R hex + G hex + B hex

Shorthand Hex Notation

When both digits in each pair are the same, you can use the shorter 3-character shorthand:

ShorthandExpands ToColor
#FFF#FFFFFFWhite
#000#000000Black
#F00#FF0000Red
#0F0#00FF00Lime
#00F#0000FFBlue
#FC0#FFCC00Gold

#ABC expands to #AABBCC - each digit is simply doubled.

Hex Opacity (Alpha Channel)

Modern CSS supports 8-digit hex codes, where the last 2 digits control transparency:

Opacity %Hex SuffixExample
100%FF#000000FF
90%E6#000000E6
75%BF#000000BF
50%80#00000080
25%40#00000040
10%1A#0000001A
0%00#00000000

This is functionally equivalent to using rgba(), just more compact directly inside a hex string.

Using Hex Colors in CSS

/* Standard 6-digit hex */
.header { background-color: #0D1B2A; }

/* Shorthand */
.text { color: #FFF; }

/* 8-digit hex with alpha */
.overlay { background: #00000080; } /* 50% black */

Hex vs RGB vs HSL

FormatExampleBest ForLimitation
Hex#FF5733Compact, copy-paste friendly, universal supportNot intuitive to read or reason about
RGBrgb(255, 87, 51)Explicit channel values, easy to understandMore verbose to type
HSLhsl(11, 100%, 60%)Intuitive adjustments (hue, saturation, lightness)Less universally used in exported design assets

The rule of thumb: use hex for final CSS values and quick copy-pasting, but reach for HSL when you need to intuitively adjust a color’s brightness or saturation without recalculating RGB channels.

Why Designers Use Hex

  • Compact: 7 characters vs. rgb(255, 165, 0) at 16 characters
  • Copy-paste friendly: No spaces or parentheses to worry about
  • Universal: Works in CSS, HTML attributes, and design tools like Figma and Photoshop
  • Easy to tweak: Changing a single hex digit adjusts the color slightly, which is useful for fine control

Common Mistakes

  1. Forgetting the # prefix — a lone FF5733 isn’t valid CSS; it needs the leading #.
  2. Using shorthand incorrectly#F5A only expands correctly when the person meant #FF55AA; if the intended color doesn’t have matching digit pairs, shorthand can’t represent it.
  3. Confusing hex opacity with hex brightness — the last two digits in an 8-digit hex code control transparency, not how “light” or “dark” the color looks.
  4. Assuming hex and RGB give different colors — they don’t; hex is just another way of writing the exact same RGB values, so converting between them never changes the actual color.
  5. Mixing up letter case — hex codes are case-insensitive (#fff and #FFF render identically), so inconsistency here is a style issue, not a bug.

Tools to Find Any Color’s Hex Code

  • Browser DevTools — most browsers include a built-in color picker when inspecting an element’s CSS
  • ColorZilla (browser extension) — lets you pick a color from anywhere on a webpage
  • macOS Digital Color Meter — a built-in utility for reading the exact color of any pixel on screen
  • Windows PowerToys Color Picker — a free Microsoft utility for grabbing hex/RGB values from anywhere on your screen

Practice Questions

  1. Convert RGB(0, 200, 100) to a 6-digit hex code.
  2. What does the shorthand #3A9 expand to in full 6-digit form?
  3. What hex suffix would you add to #FF0000 to make it 25% opaque?
  4. Is #00ff00 the same color as #00FF00? Why or why not?
  5. Why can’t the color RGB(120, 45, 200) be represented using 3-character shorthand?

(Answers: 1. #00C864 2. #33AA99 3. #FF000040 4. Yes, hex codes are case-insensitive, so both represent identical values 5. Because none of the channel pairs have matching digits (120→78, 45→2D, 200→C8 — no repeated digit pairs), so shorthand can’t compress it)

Frequently Asked Questions

Why do color codes use hexadecimal instead of decimal?

Hex is base-16, so exactly 2 digits can represent all 256 possible values (0–255) needed per color channel. Decimal would require 3 digits for the same range, making codes noticeably longer.

What is the difference between #RGB and #RRGGBB?

#RGB is shorthand notation where each digit is simply doubled to form the full code #F0F becomes #FF00FF. It only works when both digits in each channel pair happen to be identical.

Can I use hex colors in React or Tailwind CSS?

Yes. In Tailwind, you can use an arbitrary value like bg-[#FF5733] or define custom colors directly in your config file. In React inline styles, you’d write style={{color: '#FF5733'}}.

What hex code represents fully transparent?

#00000000 (using the 8-digit alpha format) or simply the CSS transparent keyword. The final two digits, 00, indicate 0% opacity.

How do I find the hex code of any color on my screen?

Use your browser’s built-in DevTools color picker, a browser extension like ColorZilla, macOS’s Digital Color Meter, or Windows PowerToys Color Picker all let you sample any pixel and instantly get its hex value.

Conclusion

Hex color codes might look cryptic at first glance, but they’re really just a compact, standardized way of writing the same RGB values you already understand split into three two-digit hexadecimal pairs. Once you know how the conversion works, reading and tweaking hex codes in a stylesheet stops being guesswork, and picking up shorthand notation or alpha transparency becomes second nature the next time you’re fine-tuning a design.


💬 Comments section enabled below.

Advertisement
Share: Twitter LinkedIn Facebook

Free tools

Learn faster with Numverto

Free number system converters, binary tools, EMI calculators, and more, with step-by-step working.

Written by

Numverto Editorial Team

Numverto Editorial Team

Founder of Numverto. MCA graduate, full-stack developer, and lifelong learner who built this platform so every student gets the explanation, not just the answer.

Related tools

Advertisement

More from Numverto Blog

Discussion

Comments

Popular Tools

View all 25 free tools → · Read tutorials · Number system guide