Color systems

CSS Color Behavior: Transparency, Tokens and Inheritance

Choose the behavior that caused the problem. These ten guides include complete examples, clear input limits and sources; eight CSS demonstrations run locally in your browser.

Choose the layer and the inherited color

Keep an opaque label clear, or make borders and an inline geometric icon follow the component foreground.

Use currentColor for Matching Labels, Borders and Inline Icons

Set the component’s foreground color once, then use currentColor where a border or inline icon should follow it. currentColor resolves from the color property on that same element, so an icon with its own color can legitimately differ from the label.

Decode tokens and read computed values

Separate alpha bytes, authored spellings, numeric precision and the color space returned by a browser.

Eight-Digit CSS HEX: Alpha Order, Short Forms and Conversion

CSS eight-digit HEX uses #RRGGBBAA: alpha comes last. Four-digit HEX repeats each nibble to make the eight-digit form. Divide the alpha byte by 255; an alpha byte of 80 is about 0.5019607843, so it is close to, but not exactly, a 50% alpha value.

Why Computed CSS Colors Become rgb(): Read Values Without False Alarms

A browser can return an rgb() string for a color authored as HEX, a name or HSL without changing the intended color. Keep the source declaration separate from the computed result, and compare values in their stated color space rather than treating different strings as automatic failures.

Check the actual reading surface

Use the existing supported alpha and gradient models for different background conditions.

Distinguish color coordinates from luminance

Compare equal HSL lightness on explicit backdrops and understand why HWB can lose its hue.

Normalize mixes and choose P3 fallbacks

Keep normalized proportions, final alpha, accepted CSS syntax and reported output gamut separate.

Keep the model with the answer

A valid CSS token, matching inherited colors and a useful contrast calculation answer different questions. Keep the alpha layer, backdrop, color space and supported inputs visible when moving between guides. These examples do not certify an entire interface or measure a physical display.

Return to all practical guides