Hex Color Codes: Complete Guide to Web Colors (2026)
A hex color code is a six-character alphanumeric code preceded by a hash symbol (#) that represents a specific color in web design and digital media. The format #RRGGBB encodes red, green, and blue channel intensities using hexadecimal notation (00 to FF), enabling 16,777,216 unique colors. Hex codes are the most widely used color format in CSS, HTML, and design tools.
Quick Answer
- 1. Format: #RRGGBB where each pair is 00-FF. #FF0000 = red, #00FF00 = green, #0000FF = blue, #000000 = black, #FFFFFF = white.
- 2. Hex codes represent 16,777,216 unique colors (256 x 256 x 256 = 16.7 million).
- 3. 93% of buyers focus on visual appearance; color influences 85% of purchasing decisions.
- 4. CSS supports 140 named colors (e.g., "coral," "tomato," "steelblue") plus hex, RGB, and HSL notation.
Convert and explore colors instantly
Convert between hex and RGB, generate palettes, and check color accessibility.
How Hex Color Codes Work
Hex color codes use the hexadecimal (base-16) numbering system to represent color channel intensities. Each color is defined by three channels: red, green, and blue (the RGB color model). In hexadecimal notation, the digits 0 through 9 represent values 0-9, and the letters A through F represent values 10-15.
Each channel pair in a hex code can represent 256 values (16 x 16 = 256, from 00 to FF). Since there are three channels, the total number of possible colors is 256 x 256 x 256 = 16,777,216. This matches the standard 24-bit color depth used by virtually all modern displays.
Breaking Down a Hex Code
Consider the hex code #3A7BDE:
- 3A = Red channel: (3 x 16) + 10 = 58 out of 255
- 7B = Green channel: (7 x 16) + 11 = 123 out of 255
- DE = Blue channel: (13 x 16) + 14 = 222 out of 255
This produces a medium blue with low red, moderate green, and high blue intensity. The equivalent RGB notation is rgb(58, 123, 222).
Essential Hex Color References
| Color | Hex Code | RGB | Use Case |
|---|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) | Backgrounds, light mode |
| Black | #000000 | rgb(0, 0, 0) | Text, dark mode |
| Pure Red | #FF0000 | rgb(255, 0, 0) | Errors, alerts |
| Pure Green | #00FF00 | rgb(0, 255, 0) | Success states |
| Pure Blue | #0000FF | rgb(0, 0, 255) | Links, CTAs |
| Gray | #808080 | rgb(128, 128, 128) | Muted text, borders |
| Coral | #FF7F50 | rgb(255, 127, 80) | Warm accents |
| Steel Blue | #4682B4 | rgb(70, 130, 180) | Professional design |
| Gold | #FFD700 | rgb(255, 215, 0) | Highlights, badges |
| Dark Slate | #2F4F4F | rgb(47, 79, 79) | Dark backgrounds |
Shorthand Hex Notation
CSS supports a three-digit shorthand for hex colors where each channel pair has identical digits. The browser expands each digit by doubling it:
- #FFF expands to #FFFFFF (white)
- #000 expands to #000000 (black)
- #F00 expands to #FF0000 (red)
- #39F expands to #3399FF (a sky blue)
Shorthand notation reduces file size slightly and is commonly used in CSS when the full six-digit code has matching pairs. You cannot use shorthand for colors like #3A7BDE where the pairs are not repeated digits.
Hex with Alpha Transparency
CSS also supports an eight-digit hex format (#RRGGBBAA) where the last two digits represent alpha (opacity). The alpha channel follows the same 00-FF range, where 00 is fully transparent and FF is fully opaque:
- #FF000080 = Red at 50 percent opacity
- #00000033 = Black at 20 percent opacity (useful for subtle overlays)
- #FFFFFF00 = Fully transparent white
The four-digit shorthand (#RGBA) also works: #F008 is equivalent to #FF000088 (red at approximately 53 percent opacity). This format is supported in all modern browsers.
Converting Between Color Formats
Hex to RGB
Convert each two-digit hex pair to a decimal number (0-255). For #C75B3A: C7 = 199, 5B = 91, 3A = 58. Result: rgb(199, 91, 58).
RGB to Hex
Convert each decimal value (0-255) to a two-digit hexadecimal number. For rgb(14, 165, 233): 14 = 0E, 165 = A5, 233 = E9. Result: #0EA5E9.
Hex to HSL
First convert hex to RGB, then apply the HSL conversion algorithm. HSL (Hue, Saturation, Lightness) is particularly useful for creating color variations. To make a color lighter, increase the L value. To make it more muted, decrease S. To shift the color, change H. For example, #C75B3A converts to approximately hsl(14, 55%, 50%).
Color Accessibility and Contrast Ratios
The Web Content Accessibility Guidelines (WCAG 2.1) establish minimum contrast ratios to ensure readability:
- Level AA (minimum): 4.5:1 contrast ratio for normal text, 3:1 for large text (18px bold or 24px regular).
- Level AAA (enhanced): 7:1 for normal text, 4.5:1 for large text.
Approximately 8 percent of men and 0.5 percent of women have some form of color vision deficiency. Common accessible color combinations include dark gray (#333333) on white (#FFFFFF) at a 12.6:1 ratio, and white text on dark blue (#1A237E) at an 11.4:1 ratio. Avoid red-green combinations, which are problematic for the most common form of color blindness (deuteranopia).
CSS Named Colors
CSS provides 140 named colors that you can use instead of hex codes. Some of the most useful include:
- Primary colors: red, blue, green, yellow, cyan, magenta
- Neutrals: white, black, gray, silver, dimgray, gainsboro, whitesmoke
- Design favorites: coral (#FF7F50), tomato (#FF6347), steelblue (#4682B4), slategray (#708090), mediumseagreen (#3CB371)
- Modern UI: dodgerblue (#1E90FF), crimson (#DC143C), darkorange (#FF8C00), indigo (#4B0082)
Named colors are convenient for prototyping and readability but hex codes offer more precise control over your exact desired shade. Most production CSS uses hex or HSL notation.
Color Trends in Web Design (2026)
Web design color trends in 2026 emphasize intentional, balanced palettes. According to industry surveys, 93 percent of buyers focus on visual appearance and color influences 85 percent of purchasing decisions:
- Earth tones: Pantone's Mocha Mousse (#A47864), clay browns, olive greens, and sandstone beiges dominate as brands seek warmth and authenticity.
- Soft neutrals: Pantone's Cloud Dancer (#F0EEE9) leads neutral web backgrounds, replacing stark white.
- Dark mode: Dark backgrounds (#121212 to #1E1E1E) with controlled neon accents for interactive elements.
- Green trust signals: Websites using green tones report a 20 percent increase in trust scores among users under 35, according to Adobe research.
The Bottom Line
Hex color codes are the foundation of digital color specification. The #RRGGBB format uses hexadecimal notation to encode 16.7 million unique colors, with each pair representing red, green, and blue intensity from 00 (none) to FF (maximum). Understanding hex codes enables you to precisely control colors in CSS, convert between color formats, ensure accessibility through proper contrast ratios, and stay current with design trends. For designers and developers, hex is the language of color on the web.
Convert and explore colors with our free hex to RGB converter and color palette generator.
Frequently Asked Questions
What is a hex color code?
A hex color code is a six-digit alphanumeric string preceded by a hash symbol (#) that represents a specific color in web design and digital graphics. The six digits are divided into three pairs: the first two represent red intensity, the middle two represent green intensity, and the last two represent blue intensity. Each pair uses hexadecimal notation (0-9 and A-F), where 00 is the minimum (no color) and FF is the maximum (full intensity). For example, #FF0000 is pure red (max red, no green, no blue), and #000000 is black (no color at all). Hex codes can represent 16,777,216 unique colors.
How do I convert hex to RGB?
To convert a hex color to RGB, split the six-digit code into three pairs and convert each pair from hexadecimal (base 16) to decimal (base 10). For #3A7BDE: the red value is 3A in hex, which is (3 x 16) + 10 = 58 in decimal. The green value is 7B, which is (7 x 16) + 11 = 123. The blue value is DE, which is (13 x 16) + 14 = 222. So #3A7BDE converts to rgb(58, 123, 222). For quick conversions, use our free hex to RGB converter tool, which handles the math instantly and shows a color preview.
What is the difference between hex, RGB, and HSL?
Hex, RGB, and HSL are three different notations for representing the same colors. Hex (#RRGGBB) uses six hexadecimal digits and is the most compact format, commonly used in CSS and design tools. RGB (red, green, blue) uses three decimal values from 0 to 255, making it intuitive for understanding color mixing. HSL (hue, saturation, lightness) uses an angle (0-360 for hue), and two percentages (saturation and lightness), making it the most intuitive for creating color variations: to make a color lighter, just increase lightness; to make it more muted, reduce saturation. All three can represent the same 16.7 million colors. Most designers write in hex but think in HSL.
What are the most popular hex colors for web design?
The most commonly used hex colors in web design include: pure white (#FFFFFF) for backgrounds, pure black (#000000) for text, and a range of blues for links and CTAs. According to studies, 93 percent of buyers focus on visual appearance, and color influences 85 percent of purchasing decisions. Popular brand colors include Facebook blue (#1877F2), Google red (#DB4437), and Spotify green (#1DB954). In 2026, design trends favor earthy tones (Pantone's Mocha Mousse #A47864), soft neutrals, and dark-mode-friendly palettes with controlled neon accents.
How do I choose accessible color combinations?
To ensure readability for all users, including those with visual impairments, follow WCAG 2.1 contrast ratio guidelines: normal text requires a minimum contrast ratio of 4.5:1 against its background, while large text (18px bold or 24px regular) requires 3:1. The highest contrast combination is black text on a white background (21:1 ratio). For colored backgrounds, test your color combinations using a contrast checker tool. Avoid relying solely on color to convey information (use icons or text labels as well). Approximately 8 percent of men and 0.5 percent of women have some form of color vision deficiency, making accessible design essential.
Convert and explore hex colors
Convert between hex, RGB, and HSL. Generate palettes. Check contrast ratios for accessibility.
Hex to RGB Converter - Free