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.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

“HTML color codes” is a familiar name for colors used on web pages, but today those colors are specified with CSS. The term usually means named colors such as purple or hexadecimal values such as #800080. CSS also supports RGB, HSL, HWB, and other color spaces.

What does “HTML color code” mean?

It is an informal, legacy umbrella term for a way to identify a color on a web page. Modern web color values belong to CSS, not HTML. MDN Web Docs puts it plainly: “It is no longer accurate to refer to colors on the web as ‘HTML color codes’ or ‘HTML color names’.” See the MDN glossary entry.

The term persists because older HTML references described colors as either hexadecimal values or a set of color names. The HTML 4.01 reference also marked using HTML elements and attributes to set colors as deprecated. For modern pages, set a CSS color property instead, for example color: #663399; or background-color: rebeccapurple;. The HTML 4.01 color reference is historical; current syntax is documented in the MDN CSS colors guide.

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

Which color formats are commonly used?

These formats are different notations for specifying colors. Changing the notation alone does not change the color.

Format What it represents Useful when
Named color A CSS keyword such as red, lightseagreen, or rebeccapurple. You want a readable value and a standard keyword matches the intended shade.
Hexadecimal Red, green, and blue components encoded as hexadecimal digits, typically #rrggbb. You need to copy an exact channel value from a design specification or another source.
RGB Red, green, and blue components, associated with the sRGB color space in the traditional form. You want to specify channel values directly or use a functional color notation.
HSL Hue, saturation, and lightness. You want to adjust those dimensions in terms that are often easier to reason about than separate RGB channels.
HWB Hue, whiteness, and blackness. You prefer to describe a color in terms of its hue and the amount of white or black.

CSS also includes color functions for CIELAB-based forms such as lab() and lch(), perceptual forms such as oklab() and oklch(), and other color spaces through color(). Consult the CSS colors guide for the broader set of supported syntax.

How do hex color codes work?

A hex color starts with # and uses hexadecimal digits to encode red, green, and blue. In the six-digit form, #rrggbb, each pair represents one channel. For example, #ff0000 is red. Hexadecimal letters are case-insensitive.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
  • #rrggbb is the six-digit form for an opaque color.
  • #rgb is a shorter shorthand; #f00 represents the same red as #ff0000.
  • #rrggbbaa adds an alpha component for opacity.
  • CSS also supports the four-digit shorthand form, which includes alpha.

Use an alpha-bearing form only when transparency is intended. The details of CSS hexadecimal notation are in the MDN hex color reference.

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

How do named colors differ from exact values?

Named colors make styles easy to read: blue communicates intent more clearly than a numeric sequence at a glance. But the keyword set is limited, so it cannot name every exact shade in a design. MDN Web Docs lists over 160 named colors; the retrieved reference does not state a publication year. See the named color reference.

Keywords are case-insensitive. CSS also has the special named values transparent and currentColor. Use a named color when its standard shade is suitable; choose an explicit value when a project calls for a precise color.

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

How should you choose a notation?

  • Choose a named color for a quick, readable style when the standard keyword is the shade you want.
  • Choose hex or RGB when copying exact red, green, and blue channel values from a specification.
  • Choose HSL when you want to adjust hue, saturation, or lightness as separate dimensions.
  • Use alpha in hex or a functional color form only if the color needs transparency.

To inspect equivalents, MDN’s CSS color guide and converter can show a selected color in RGB, HEX, HSL, and HWB. Those values are alternate representations of the same color.

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.

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