October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
ThatPainter
accessibility

What Is a Color Hex Code? Definition, Examples & Alternatives

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ThatPainter is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Learn More

A color hex code is a compact hexadecimal way to write an sRGB color, usually in the form #RRGGBB. Each pair represents the intensity of one red, green, or blue channel. For example, #FF5733 is the same basic color as rgb(255 87 51).

Hex is a notation—not a separate color model or a guarantee that a color will look identical on every screen or in print.

What does a hex color code look like?

The familiar CSS hex format is:

#RRGGBB

The # identifies the value as a CSS hexadecimal color. The six characters are hexadecimal digits: 0–9 and A–F. Letters are case-insensitive, so #00FF00 and #00ff00 represent the same color.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#  RR  GG  BB
   red green blue

For #FF5733:

  • FF is red at 255.
  • 57 is green at 87.
  • 33 is blue at 51.

Therefore:

#FF5733 = rgb(255 87 51)

In ordinary CSS, these channel values describe a color in the sRGB color space. See the W3C CSS Color Module Level 4.

#1 Best Overall
Sale
Pro Grade Paint Brushes, Paint Brush Set for Walls, Trim & Stain, 5-Piece
  • COMPLETE 5-PIECE BRUSH SET FOR EVERY PAINTING TASK — Includes 1 Inch Flat, 1.5 Inch Angle, 2 Inch Flat, 2 Inch Angle Stubby, and 2.5 Inch Angle brush giving you every size professional painters use daily. Get all 5 for less than the price of a single brush from hardware store brands — professional grade performance at a fraction of the cost. Perfect for walls, trim, cabinets, doors, furniture, and detailed cutting-in work on any project.
  • ZERO BRISTLE LOSS — GUARANTEED BY PRECISION ADHESIVE BONDING — Every bristle is locked in place with precision-set adhesive that keeps them in the brush — not in your paint job. The coated steel ferrule provides structural support while the adhesive bond ensures clean performance on every stroke. Premium SRT synthetic filaments load more paint and release it evenly for a smooth streak-free finish on walls, ceilings, and trim. Works with latex, oil-based paint, primer, sealer, and wood stain.
  • INCLUDES THE ANGLE STUBBY MOST SETS LEAVE OUT — Professional painters know the 2 Inch Angle Stubby is the go-to brush for tight cabinet interiors, window sashes, inside corners, and detailed trim where standard angle brushes are too long. Combined with the 1.5 and 2.5 inch angle sash brushes you have precision cutting-in covered at every scale — baseboards, crown molding, door casings, and ceiling lines.
  • FLAT BRUSHES FOR BROAD SMOOTH COVERAGE ON ANY SURFACE — The 1 and 2 inch flat brushes deliver even coverage on walls, furniture, shelving, doors, fences, decks, and wood surfaces. Ideal for applying primers, stains, varnishes, polyurethane, and specialty coatings. Solid wood handles provide all-day comfort and control for both professional contractors and weekend DIY homeowners tackling interior or exterior painting projects.
  • TRUSTED BY PROFESSIONAL PAINTERS AND CONTRACTORS NATIONWIDE — Pro Grade delivers professional-grade results at a price that makes sense for crews who go through brushes on every job. Ideal for property managers, remodeling contractors, apartment turnover crews, maintenance teams, and commercial painting operations. Backed by thousands of verified reviews from working painters. Washable and reusable for multiple projects.

How do color hex codes work?

Hexadecimal is a base-16 numbering system. It uses:

0 1 2 3 4 5 6 7 8 9 A B C D E F

The letters stand for values 10 through 15: A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.

Each RGB channel uses two hexadecimal digits, from 00 to FF. That equals decimal values from 0 to 255. A six-digit code can therefore represent:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
256 × 256 × 256 = 16,777,216

opaque 8-bit-per-channel sRGB combinations. This mathematical total does not mean every monitor displays every value distinctly, or that the same code will appear identical on all calibrated and uncalibrated screens.

Common hex color examples

Hex code RGB equivalent Common description
#000000 rgb(0 0 0) Black
#FFFFFF rgb(255 255 255) White
#FF0000 rgb(255 0 0) Pure red
#00FF00 rgb(0 255 0) Pure green
#0000FF rgb(0 0 255) Pure blue
#FFFF00 rgb(255 255 0) Yellow
#00FFFF rgb(0 255 255) Cyan
#FF00FF rgb(255 0 255) Magenta
#808080 rgb(128 128 128) Gray
#FFA500 rgb(255 165 0) Orange
#800080 rgb(128 0 128) Purple
#7B3F00 rgb(123 63 0) Chocolate brown

Descriptions such as “orange” or “chocolate” are human-facing labels. The code itself specifies channel values. For example, Canva uses #7B3F00 as a chocolate color reference, but color names can vary between palettes and tools.

How to use a hex code in HTML and CSS

Hex values can be used anywhere CSS accepts a color, including text, backgrounds, borders, outlines, shadows, gradients, and SVG fills or strokes.

Rank #2
Paint Brushes Set of 24 Pieces with Canvas Brush Case
  • DESIGNS FOR PERFECT PAINTING: Total 24 pieces different functionals paint brushes are providing perfect experience of watercolors and acrylics, these artist paint brush set covers all wide range of projects and features 100-percent natural wood handles and nylon hair, lightweight and easy to hold
  • EASY TO ORGANIZE AND CARRY: Free canvas brush case to protect all brushes very well, and easy to hold all of 24 pieces brush, make your painting whenever and wherever possible
  • GREAT GIFT: An ideal gift for all kids to find more back-to-school necessary stationery easy way and ideas here. It provides a unique and practical present
  • QUALITY ENSURE: All of the components are under our door to door quality control system; quality assurance process delivers outstanding quality and durability
  • ALL BRUSH TYPES: The set contains fan brushes, bright brushes, detailed brushes, round brushes, mop brushes, and angle brushes. All types are prefect working with all paint types
body {
  background-color: #F4F7FB;
  color: #1F2937;
}

.button {
  background-color: #2563EB;
  border: 1px solid #1D4ED8;
}

.notice {
  color: #7C3AED;
}

The corresponding HTML might be:

<p class="notice">This text uses a hex color.</p>

Hex is commonly associated with HTML and CSS, but it also appears in design software, brand guidelines, image editors, and developer tools.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CSS custom properties

Design systems often store reusable colors as variables:

:root {
  --brand-blue: #2563EB;
  --brand-dark: #1E3A8A;
}

.button {
  background-color: var(--brand-blue);
}

Three-digit shorthand: #RGB

CSS supports a three-digit shorthand form. Each digit is duplicated:

#F00 = #FF0000
#0F0 = #00FF00
#00F = #0000FF
#FFF = #FFFFFF
#ABC = #AABBCC

It is not correct to insert zeros. For example, #ABC expands to #AABBCC, not #A0B0C0.

Only six-digit values whose pairs repeat can be shortened. #AABBCC becomes #ABC, and #FF8800 becomes #F80. #123456 has no three-digit equivalent. The shorthand has 4,096 possible combinations, compared with about 17 million for six-digit notation. See the W3C CSS Color Module Level 3.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Four- and eight-digit hex codes: transparency

Traditional six-digit hex has no alpha component. Modern CSS also supports:

Rank #3
Soucolor Acrylic Paint Brushes Set, 20 Pcs Pointed Tip Artist Paintbrushes
  • Great Value Pack Artist Paint Brushes: Soucolor 20 brushes in 10 sizes professional paintbrushes set — no shedding, holds paint well, cleans easily, Acrylic, watercolor, oil, gouache, Halloween pumpkin decoration & face painting, rock painting, ceramics. Fantastic high quality gifts for creative, artistic siblings to share!
  • Awesome Set of Paint brushes: Professional paint brushes can cover all of your needs. The multi-purposed brushes are ideal for Watercolor, Oil, Gouache, enamel, Acrylic Painting, Body, Nail, Face Painting, Miniature, Model, Wood, Glass, Cup, Ceramic, Fine work, Art class, Craft Art Painting, DIY Art Crafts etc.
  • Soft and long-lasting: The bristles are soft and strong, with nickel metal ferrules and blue wooden handles. After cleaning, the bristles will become soft and fluffy again and will not fall off.
  • Easy to clean: it’s very convenient to Wash well in soap and water. Retain shape after drying. the brushes hold up very well. Nice selection to beginners and professionals. Keep them clean and they last a long time.
  • Halloween Pumpkin Ceramic Crafts Supplies: A Great painting gift for family, friends, kids, girls, women, student, classmate, teacher. For using in school, travel or used in the home and office.
#RGBA
#RRGGBBAA

The final digit or pair controls alpha, or opacity:

  • 00 is fully transparent.
  • 80 is approximately 50% opacity.
  • FF is fully opaque.
#00000000  /* transparent black */
#00000080  /* black at approximately 50% opacity */
#FF000080  /* red at approximately 50% opacity */
#0000FFCC  /* blue at approximately 80% opacity */
#F008      /* shorthand for #FF000088 */

In CSS eight-digit notation, alpha comes last: #RRGGBBAA. The same translucent value can look different over different backgrounds. Support is broad in modern browsers, but historical browsers and nonbrowser applications may not support every form; check the target software. The MDN <hex-color> reference documents the syntax.

How to convert hex to RGB

Split the six-digit code into three pairs, then convert each pair from base 16 to decimal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For #1A3F6F:

1A  3F  6F
red green blue
1A = 26
3F = 63
6F = 111

So:

#1A3F6F = rgb(26 63 111)

The formula for a two-digit pair is:

first digit × 16 + second digit

For example, 1A = 1 × 16 + 10 = 26.

To convert RGB to hex, convert each decimal channel from 0–255 into a two-digit hexadecimal value and join the pairs:

rgb(255, 87, 51) → #FF5733

A tool such as HexConverter can handle one-off hex, RGB, and HSL conversions, but conversion alone does not check accessibility or print accuracy.

Hex vs. RGB, HSL, CMYK, and LAB

These options are not all interchangeable. Hex and RGB are usually alternative notations for the same sRGB channel values; HSL reorganizes color into hue, saturation, and lightness; CMYK is intended for ink-based printing; and LAB is used in more specialized, perceptual and color-managed workflows.

Rank #4
Bates- Paint Brushes, 6 Pack, Treated Wood Handle Brushes for Walls
  • Bates paint brushes come in a convenient 6 pieces with 3 flat and 3 angled bristle styles, including (1”, 1.5”, 2”) flat and (1.5”, 2”, 2.5”) angled bristles, perfect for tackling any surface painting or staining job.
  • The sturdy natural bristles of each brush are designed to hold more paint, creating a smoother finish with fewer streaks and saving you time on the job.
  • The lightweight wooden handles provide extra comfort and ease during long painting processes like walls, trims, cabinets, and doors.
  • These versatile brushes are ready-to-use, easy to clean, and can be reused multiple times, making them economical as well as reliable tools for any painting project.
  • Bates paint brushes can be used for both oil-based paints as well as latex stains and are ideal for home or commercial projects such as decks, fences or DIY painting jobs.
Format Example Best for Limitations
Hex #2563EB Compact, copyable CSS and design tokens Less intuitive to adjust manually
Modern RGB rgb(37 99 235) Readable numeric channels and explicit alpha Longer than hex
Legacy RGBA rgba(37, 99, 235, 0.5) Older codebases using comma syntax Older syntax; not required for modern transparency
HSL hsl(217 83% 53%) Creating lighter, darker, more muted, or more vivid variants Not perceptually uniform
Named color royalblue Readable prototypes and teaching examples Limited list and poor fit for exact branding
CMYK Varies by profile Physical printing Screen hex values do not guarantee printed appearance
LAB and newer color spaces Varies by color space Professional color correction, wide-gamut, and managed workflows More complex and dependent on tooling and support

Adobe’s color-code guide discusses RGB, HSL, LAB, HSB, HWB, and CMYK as common color systems or alternatives.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When should you use HSL?

HSL can be convenient when people need to adjust a color conceptually:

  • Hue is the position around the color wheel.
  • Saturation controls how vivid or muted the color is.
  • Lightness controls the nominal light-to-dark position.
color: hsl(217 83% 53%);

For example, a design system might expose lightness as a control for creating button variants. However, equal HSL lightness values do not guarantee equal perceived brightness across different hues.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should you use RGB or rgba()?

Use RGB-style syntax when decimal channels are easier to inspect, when code manipulates channels numerically, or when a project already uses CSS color functions consistently. Modern CSS supports alpha directly:

color: rgb(37 99 235 / 50%);

Older code may use:

color: rgba(37, 99, 235, 0.5);

rgba() is not the only way to express transparency: modern rgb(), four- and eight-digit hex, and other CSS color functions can also include alpha.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When are CMYK or LAB preferable?

CMYK is generally the better starting point for physical print because it describes cyan, magenta, yellow, and black inks. A hex value can be converted to CMYK, but the result is not a guarantee of the final printed color. Paper, ink, printer, profiles, and production conditions all matter. For print-critical work, use the printer’s requested profile or an approved CMYK or Pantone specification.

Best Value
Sale
AROIC 10 Pcs Paint Brushes, Acrylic Oil Watercolor Painting Brush Set
  • 【All sizes of art brushes】: The 10 sizes of multi-functional brushes have various shapes, making the mixing color easier, which is very suitable for artists, students, teenagers, children and painters at all levels. Wonderful Present ideas for friends and family who like painting!
  • 【general brush set】: Professional paint brush can meet all your needs. Multifunctional brush is very suitable for watercolor, oil, gouache, acrylic painting, body, nail, face painting, miniature, model, ceramics, arts and crafts painting, etc.
  • 【high quality process】: It is designed with anti falling bristles, anti-rust nickel ferrule and solid wood handle. You can use the brush to focus on the painting and always be creative.
  • 【easy to maintain】: After using the brush, it is very convenient to clean the brush with warm soapy water and reshape the tip of the brush. Air dry the brush and place it on top of the top for long use.
  • 【100% satisfaction guarantee - buy now】1 packs of set brushes, you can also get friendly customer service, any questions feel free to contact us, within 24 hours to help you! There is no risk in buying our paint brush kit.

LAB is more relevant to color correction, device-independent communication, perceptual adjustment, and professional imaging. It is not automatically a better choice for ordinary web styling and is more complex than hex.

Which color format should you choose?

  • Website or interface styling: Use hex or RGB, depending on your team’s conventions and whether numeric channels are useful.
  • Reusable design tokens: Use hex for stable opaque sRGB values; use HSL or a modern color function when systematic adjustment is important.
  • Transparency: Use eight-digit hex, modern RGB alpha syntax, or the syntax already established by the project.
  • Quick prototypes: Named CSS colors are readable, but avoid them for precise brand matching.
  • Print: Follow the printer’s color profile and production specification rather than treating hex as a print standard.
  • Professional imaging: Consider LAB or another managed color space when the workflow requires it.

Hex colors and accessibility

A hex code is not accessible or inaccessible by itself. Accessibility depends on the combination of foreground and background, text size and weight, states, and how information is communicated.

Under WCAG 2.2 Success Criterion 1.4.3, normal text generally requires a contrast ratio of at least 4.5:1; large text generally requires 3:1, subject to the stated exceptions. Check the actual color pair with a contrast tool rather than judging it by eye. See W3C’s Contrast Minimum guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not rely on color alone to communicate meaning. Add text, icons, patterns, labels, or another visual cue:

.error {
  color: #B91C1C;
  border: 2px solid #B91C1C;
}

.error::before {
  content: "Error: ";
  font-weight: bold;
}

See W3C’s guidance on using color.

Common mistakes

  1. Leaving out the hash: 336699 is not a valid CSS hex color declaration; use #336699.
  2. Reading six digits as six decimal numbers: the code contains three two-digit hexadecimal channel values.
  3. Reversing the channel order: CSS hex uses red, green, blue—#RRGGBB.
  4. Expanding shorthand incorrectly: #ABC means #AABBCC, not #A0B0C0.
  5. Putting alpha first: CSS uses #RRGGBBAA, so #FF000080 is semi-transparent red.
  6. Assuming hex is print-proof: screen colors require conversion and color management for reliable physical output.
  7. Calling one color accessible: test the complete foreground/background combination.
  8. Assuming universal support: modern CSS widely supports these forms, but old browsers and nonbrowser tools may differ.
  9. Assuming identical appearance everywhere: calibration, gamut, color management, lighting, and display hardware affect what viewers see.

FAQ

What is a hex code in simple terms?

It is a short way to write a digital RGB color using base-16 numbers.

Is hex the same as RGB?

Usually, yes in CSS: hex and RGB are different notations for the same sRGB channel values.

Can hex codes include transparency?

Yes. Modern CSS supports #RGBA and #RRGGBBAA, although older six-digit hex has no alpha component.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Are hex codes case-sensitive?

No. Hexadecimal letters can be uppercase or lowercase.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.