🎨 HTML Color Picker 2026
Pick any color and instantly get HEX, RGB, RGBA, HSL, HSLA, CMYK, and AARRGGBB codes. Features image eyedropper, color harmony generator, WCAG contrast checker, CSS variable output, and a complete guide to color theory, hex math, and web accessibility.
🌈 Color Harmony Generator
♿ WCAG Contrast Checker
📷 Pick Color from Image
📷 Click to upload or drag & drop any image
Then click anywhere on the image to extract its exact color
🏷️ CSS Named Colors Quick-Picker
📖 How to Use This HTML Color Picker
-
1Pick Your Color — Three Ways
Use the browser's native color picker (click the colored input), type a HEX code directly (e.g., #FF5733), or drag the RGB sliders to mix red, green, and blue channels (0–255 each). The alpha slider controls opacity (0% = fully transparent, 100% = fully opaque). All methods sync in real time. The large color swatch updates instantly to show your selected color with the correct transparency against a checkered background.
-
2Copy Any Color Format — HEX, RGB, HSL, CMYK, AARRGGBB
The output panel shows your color in 8 formats simultaneously: HEX (#RRGGBB for CSS), RGB (rgb(R,G,B) for CSS), RGBA (with alpha for transparency), HSL (hsl(H,S%,L%) — intuitive for adjustments), HSLA (HSL with transparency), CMYK (for print design), AARRGGBB (for Android/Flutter apps), and a ready-to-paste CSS custom property declaration. Click any "Copy" button to copy to clipboard instantly.
-
3Generate Color Harmonies Automatically
The Color Harmony Generator shows 6 harmonically related colors: your base, complementary (180° opposite on the color wheel), two analogous colors (±30°), two triadic colors (+120° / +240°), and split-complementary colors (±150°). Each harmony shows the HEX code and a preview swatch. Click any harmony swatch to load that color into the picker. These are ideal for building a cohesive color palette for your website, brand, or design project.
-
4Check WCAG Accessibility Contrast
The contrast checker tests your selected color as the text color against both white (#FFFFFF) and black (#000000) backgrounds. It calculates the relative luminance using the WCAG 2.2 formula and shows the contrast ratio. Badges indicate WCAG AA (4.5:1 normal, 3:1 large) and AAA (7:1 normal, 4.5:1 large) compliance. Use this to ensure your color choices meet accessibility standards — required by ADA, Section 508, and EN 301 549 in the EU.
-
5Extract Colors from Any Image
Upload a PNG, JPEG, WebP, or GIF image using the eyedropper tool. After uploading, click any pixel on the image — the picker instantly extracts that pixel's exact RGB value and converts it to all formats (HEX, HSL, CMYK, etc.). This is perfect for brand color matching, extracting a specific color from a logo or photograph, or building a palette inspired by an image. The Canvas API ensures accurate color extraction even for complex images.
📐 Color Math Formulas — MathJax Rendered
\( \text{HEX} = \#R_HR_LG_HG_LB_HB_L \quad \text{where each digit } d \in \{0\text{–}9, A\text{–}F\} \)
\( R_{10} = 16 \times R_H + R_L \quad \text{(similarly for G and B)} \)
\( \text{Example: \#FF5733} \Rightarrow R = 16 \times 15 + 15 = 255,\; G = 16 \times 5 + 7 = 87,\; B = 16 \times 3 + 3 = 51 \)
\( \text{Reverse: } R_{16} = \left\lfloor\frac{R}{16}\right\rfloor \text{ (high nibble)}, \quad R_{16L} = R \bmod 16 \text{ (low nibble)} \)
\( \text{Short HEX: \#RGB} \Rightarrow \#RRGGBB \text{ (duplicate each digit: \#F0A} \Rightarrow \#FF00AA\text{)} \)
parseInt("FF", 16) = 255; (255).toString(16).toUpperCase() = "FF".\( \text{Normalize: } R' = R/255,\; G' = G/255,\; B' = B/255 \)
\( M = \max(R',G',B'), \quad m = \min(R',G',B'), \quad \delta = M - m \)
\( L = \frac{M + m}{2} \qquad S = \begin{cases} 0 & \text{if } \delta = 0 \\ \dfrac{\delta}{1 - |2L - 1|} & \text{otherwise} \end{cases} \)
\( H = \begin{cases} 60° \times \left(\dfrac{G'-B'}{\delta} \bmod 6\right) & \text{if } M = R' \\ 60° \times \left(\dfrac{B'-R'}{\delta} + 2\right) & \text{if } M = G' \\ 60° \times \left(\dfrac{R'-G'}{\delta} + 4\right) & \text{if } M = B' \end{cases} \)
\( R' = R/255,\; G' = G/255,\; B' = B/255 \)
\( K = 1 - \max(R', G', B') \quad \text{(Black key)} \)
\( C = \frac{1 - R' - K}{1 - K},\quad M = \frac{1 - G' - K}{1 - K},\quad Y = \frac{1 - B' - K}{1 - K} \quad \text{(when } K \neq 1\text{)} \)
\( \text{Example: \#FF5733 → } K = 1 - 1 = 0,\; C=0\%,\; M=\frac{1-87/255}{1}=66\%,\; Y=\frac{1-51/255}{1}=80\% \)
\( c_{\text{lin}} = \begin{cases} \dfrac{c_{\text{sRGB}}}{12.92} & \text{if } c_{\text{sRGB}} \leq 0.04045 \\ \left(\dfrac{c_{\text{sRGB}} + 0.055}{1.055}\right)^{2.4} & \text{otherwise} \end{cases} \quad (c \in \{R,G,B\}) \)
\( L = 0.2126 \cdot R_{\text{lin}} + 0.7152 \cdot G_{\text{lin}} + 0.0722 \cdot B_{\text{lin}} \)
\( \text{Contrast Ratio} = \frac{L_1 + 0.05}{L_2 + 0.05} \quad \text{where } L_1 \geq L_2 \)
\( \text{WCAG AA: CR} \geq 4.5:1 \text{ (normal text)}, \geq 3:1 \text{ (large)} \quad \text{WCAG AAA: CR} \geq 7:1 \text{ (normal)}, \geq 4.5:1 \text{ (large)} \)
💡 Complete Guide to HTML Color Codes, Color Theory, and Web Accessibility
Color is the most emotionally and psychologically powerful design element in digital interfaces — and in HTML/CSS, color is encoded in mathematical formats that allow computers to reproduce any of over 16 million distinct shades on your screen. Understanding how these formats work is not just a technical curiosity: it is essential knowledge for web developers, UI/UX designers, brand managers, digital artists, and anyone who creates or curates content for the web. Whether you are setting a brand's primary color, ensuring your text is readable by users with visual impairments, or extracting a color from a client's logo to implement in CSS, you need fluency in at least three color formats: HEX, RGB, and HSL.
The history of color in computing is a story of rapidly expanding gamuts. The original IBM PC (1981) displayed only 4 colors (CGA standard). EGA (1984) expanded to 16 colors. VGA (1987) introduced 256 colors from a palette of 262,144. SVGA and later standards in the early 1990s introduced 16-bit "High Color" (65,536 colors) and 24-bit "True Color" (16,777,216 colors). Modern displays support 10-bit color (1.07 billion colors), HDR (High Dynamic Range), and wide color gamuts like DCI-P3 (used in Apple displays and cinema) and BT.2020 (broadcast standard). CSS Color Level 4 and CSS Color Level 5 (2023) introduce the oklch(), oklab(), display-p3, and color-mix() functions to support these wider gamuts directly in web CSS.
HEX Color Codes in Web History
HEX color codes became the web standard with the introduction of HTML 3.2 (1997) and CSS 1 (1996). The format #RRGGBB was chosen for its compactness — 7 characters beats writing "rgb(134,25,143)". Netscape originally introduced the HTML color attribute (<body bgcolor="#000000">) in 1994. Modern CSS allows HEX codes of 4 or 8 characters too: #RGBA (4-digit with alpha) and #RRGGBBAA (8-digit with alpha), supported in all major browsers since 2016 (CSS Color Level 4). HEX is defined in the W3C CSS Color Module specification maintained by the CSS Working Group (CSSWG).
Why Monitors Use Additive RGB
Screens emit light rather than reflect it, making them additive color systems. RGB Red + Green = Yellow. Red + Blue = Magenta. Green + Blue = Cyan. All three at full intensity (255,255,255) = White. All at zero = Black. This mimics how human photoreceptors (L, M, S cones — sensitive to long, medium, short wavelengths) process color. Each pixel on an LCD/OLED display contains three sub-pixels: one red, one green, one blue. The monitor's firmware maps the 0–255 integer values to precise voltages that control each sub-pixel's brightness. The overall RGB gamut covers roughly 35% of the human-visible color space (the CIE 1931 chromaticity diagram). sRGB — the standard web colorspace — was defined by W3C and IEC in 1999 and remains the default assumption for CSS colors.
HSL: Designed for Human Intuition
HSL (Hue-Saturation-Lightness) was introduced by Alvy Ray Smith at PARC (Xerox Palo Alto Research Center) in 1978 as a more intuitive alternative to RGB for designers. While RGB describes a color by its component wavelengths, HSL describes it the way a painter would: what color is it (hue), how vivid is it (saturation), and how light or dark is it (lightness). In CSS, changing hsl(73, 50%, 33%) to hsl(73, 50%, 60%) always produces a lighter version of the same color — impossible to achieve intuitively in RGB alone. HSL is recommended for generating color scales, palette shades, and hover states in design systems.
Color Accessibility — WCAG 2.2
Web Content Accessibility Guidelines (WCAG) 2.2, published by W3C in October 2023, requires sufficient color contrast between text and its background. Success Criterion 1.4.3 (Silver/AA level): minimum contrast ratio of 4.5:1 for normal text; 3:1 for large text (18pt+ regular or 14pt+ bold). Criterion 1.4.6 (Gold/AAA level): 7:1 for normal; 4.5:1 for large. Legal requirements: ADA (US, Section 508), EN 301 549 (EU), and Equality Act regulations (UK) all reference WCAG. Approximately 8% of men and 0.5% of women have color vision deficiency. Designing for sufficient contrast also benefits users in bright sunlight, on low-quality displays, and those with age-related visual changes.
oklch(L C H) — perceptually uniform lightness; changing L gives equally-spaced lightness steps perceived as equal by the human eye. oklab(L a b) — device-independent Lab color space. color-mix(in oklch, blue 30%, red) — mix colors in any color space. color(display-p3 R G B) — access the wider P3 gamut (used in iPhone and Mac displays since 2016). lch() and lab() — CIE standard perceptually uniform spaces. These features have near-100% browser support as of 2024 and are the future of color management on the web.
❓ Frequently Asked Questions — HTML Color Codes
What is a HEX color code and how do I read it?
#RRGGBB. Each pair represents one channel (0–255): #FF0000 = pure red (R=255, G=0, B=0). #000000 = black. #FFFFFF = white. #808080 = 50% gray (R=G=B=128). Reading: split #6B7D2A into pairs: 6B (R), 7D (G), 2A (B). Convert to decimal: 6B₁₆ = 6×16+11 = 107; 7D₁₆ = 7×16+13 = 125; 2A₁₆ = 2×16+10 = 42. So #6B7D2A = rgb(107, 125, 42) — an olive green. HEX codes are case-insensitive: #ff0000 = #FF0000.
What is the difference between HEX, RGB, and HSL color codes?
#RRGGBB): Compact, widely supported, base-16. Best for copy-pasting exact colors. 7 characters vs up to 20+ for RGB. Used in HTML attributes, CSS, SVG.
RGB (rgb(R, G, B)): Decimal 0–255 for each channel. Most intuitive for understanding color mixing. Can include alpha with rgba(R, G, B, A) where A is 0–1.
HSL (hsl(H, S%, L%)): Hue (color wheel 0–360°), Saturation (vividity 0–100%), Lightness (dark/light 0–100%). Best for making color variations systematically — changing L from 33% to 55% always gives a lighter version of the same color. Recommended for design systems. Modern CSS also supports oklch() which is even more perceptually uniform than HSL.
How do I convert HEX to RGB?
#FF5733: FF → 255 (R); 57 → 87 (G); 33 → 51 (B). Result: rgb(255, 87, 51).
JavaScript: parseInt("FF", 16) = 255. For any color #RRGGBB: R = parseInt(hex.slice(1,3), 16). Three-character shorthand #RGB expands to #RRGGBB by doubling each character: #F0A → #FF00AA.
Our tool shows the RGB equivalent of any color in real time, along with all other formats.
How do I convert RGB to HEX?
rgb(107, 125, 42): 107 → 6B; 125 → 7D; 42 → 2A. Result: #6B7D2A.
JavaScript: (n).toString(16).padStart(2, '0').toUpperCase(). For 107: (107).toString(16) = "6b". "6b".padStart(2,'0') = "6b" (already 2 chars). Uppercase: "6B". Full HEX: "#" + toHex(R) + toHex(G) + toHex(B).
If you want a 3-character shorthand: only possible when each channel's two hex digits are identical (e.g., #FF = F, #AA = A). #6B7D2A cannot be shortened.
What is RGBA and how does alpha/transparency work?
rgba(R, G, B, A) where A is 0–1 (0 = fully transparent, 1 = fully opaque).
Examples: rgba(255, 0, 0, 0.5) = 50% transparent red. rgba(0, 0, 0, 0.8) = 80% opaque black overlay (allows 20% of background to show). rgba(255, 255, 255, 0) = fully transparent white (invisible).
Modern CSS also supports 8-digit HEX with alpha: #FF000080 = 50% transparent red (80₁₆ = 128 ≈ 0.5 × 255). And the original 4-digit shorthand: #F008 = #FF000088. The CSS3 opacity property applies transparency to the entire element (including children), while rgba() only transparentizes the specific color value.
What is CMYK color and when should I use it?
What is AARRGGBB and when is it used?
#FFFF5733 = fully opaque orange; #80FF5733 = 50% transparent orange (80₁₆ = 128/255 ≈ 50%).
In Android XML resources: android:textColor="#FF6B7D2A". In Flutter (Dart): Color(0xFF6B7D2A) — prefix 0x for Dart hex literal. The Java/Kotlin equivalent: Color.parseColor("#FF6B7D2A"). Converting alpha: multiply 0–1 by 255, round, convert to hex. opacity 0.75 → 0.75 × 255 = 191 → BF. Our tool calculates the AARRGGBB value from the RGB + alpha slider in real time.
What is the color code for red, blue, green, black, and white?
#FF0000 · RGB rgb(255,0,0) · HSL hsl(0,100%,50%).
Pure Green: HEX #00FF00 · RGB rgb(0,255,0) · HSL hsl(120,100%,50%). (Note: CSS named color "green" is #008000, half-brightness.)
Pure Blue: HEX #0000FF · RGB rgb(0,0,255) · HSL hsl(240,100%,50%).
Black: HEX #000000 · RGB rgb(0,0,0) · HSL hsl(0,0%,0%).
White: HEX #FFFFFF · RGB rgb(255,255,255) · HSL hsl(0,0%,100%).
Gray (50%): HEX #808080 · RGB rgb(128,128,128) · HSL hsl(0,0%,50%).
How do I find a color's complementary, triadic, or analogous colors?
hsl(73,50%,33%) → complementary: hsl(253,50%,33%) — high contrast pairs.
Analogous: ±30° from H. Three adjacent colors on the wheel — seem naturally harmonious.
Triadic: H + 120° and H + 240°. Three equidistant colors — vivid and balanced.
Split-complementary: ±150° from H (two colors flanking the complement) — less harsh than complementary.
Tetradic (Square): H, H+90°, H+180°, H+270°. Richest palette, difficult to balance.
Our tool generates all these automatically. Formula: newH = (H + degrees) % 360. Use the same S% and L% values to maintain cohesive brightness and saturation across the palette.
What are CSS named colors?
aliceblue to yellowgreen. They were defined by X11 color names and Internet Explorer's Windows color support. Notable additions: rebeccapurple (#663399) — added to CSS in 2014 in memory of Rebecca Alison Meyer, daughter of CSS author Eric Meyer. transparent is shorthand for rgba(0,0,0,0). CSS Color Level 4 added the keyword currentcolor (inherits the element's text color). All 148 named colors are case-insensitive and can be used anywhere a color value is accepted: background-color: cornflowerblue;. Our Named Colors picker shows all common ones with hex values.
How do I extract a color from an image?
ctx.getImageData(x, y, 1, 1).data, which returns a Uint8ClampedArray of [R, G, B, A] (0–255 each). The picked color is instantly loaded into the main color picker and all output formats update. Note: browser security prevents reading pixels from external URLs (CORS restriction) — you must download the image first before uploading. This applies to all browser-based color pickers.
What color format should I use in CSS for web design?
#RRGGBB) is most compact and common. Use it for color values that don't need transparency.
For transparency: rgba(R, G, B, A) or 8-digit HEX (#RRGGBBAA).
For design systems/themes: CSS Custom Properties (variables) with HSL: --brand-primary: hsl(296, 70%, 33%); — allows easy lightness/saturation adjustments by overriding variables.
For modern wide-gamut displays (P3): color(display-p3 R G B) (use with @supports for fallback).
For perceptually uniform variations: oklch(L C H) — the most accurate model for generating accessible color scales. Most web teams use HEX for brand colors, rgba() for overlays, and CSS variables with HSL for scalable design systems.