Color

Color Contrast Checker Guide: WCAG Ratios, AA/AAA and Transparency

·

A color contrast checker compares the relative luminance of foreground and background colors. ToolMellow calculates the WCAG 2.2 sRGB contrast ratio and shows the five normal-text, large-text and essential non-text threshold results. Edit Text color, Background color or Canvas behind transparency; the result recalculates immediately in your browser.

The result describes the entered solid-color pair after the tool’s transparency composition. Use it to choose and document colors, then inspect the real content, typography, adjacent surfaces and interaction states. A passing pair is one piece of accessibility evidence, not a complete website audit or a guarantee that every reader will find the text comfortable.

Contrast checker

How to check a text and background pair

Enter the actual text and background color values. Text color starts at #294C39, with Background color and Canvas behind transparency both set to #FFFFFF. CSS names, HEX, RGB/RGBA and HSL/HSLA are accepted within the supported grammar. Color-value syntax remains CSS syntax even when the interface language changes.

Read the ratio and the row matching your intended use. Editing colors or the canvas recalculates the result immediately; an invalid value shows an error and hides the report and preview until the value is valid again. Preview text, Text size (px) and Bold text help inspect the example. Copy report and Download report preserve a snapshot of the then-current calculation.

  • Use the colors applied to the actual element and surface, including the relevant theme and state.
  • For transparency, identify the opaque surface underneath rather than assuming a white page.
  • Save the pair and full-precision result, then review the real component before changing shared design tokens.

The five results: normal text, large text and essential graphics

The table below gives the tool’s inclusive minimum comparisons: the raw ratio must reach the listed value. Normal and large text each have AA and AAA rows. The essential UI/graphics row uses a 3:1 comparison associated with non-text contrast; deciding whether a particular part or state is covered still requires its real context.

All five rows remain visible when you change preview size or weight. The preview’s normal/large message does not replace the table or raise the numeric ratio. A normal-text AA pass does not automatically satisfy normal-text AAA, and a large-text pass should not be used for smaller body text.

The five results: normal text, large text and essential graphics
UseMinimum ratioReport flag
Normal text · AA4.5:1normalAA
Normal text · AAA7:1normalAAA
Large text · AA3:1largeAA
Large text · AAA4.5:1largeAAA
Essential UI and graphics · AA3:1nonTextAA

W3C WCAG 2.2: Criteria, large-scale text, relative luminance and contrast ratioW3C Understanding 1.4.3: Contrast (Minimum)W3C Understanding 1.4.6: Contrast (Enhanced)W3C Understanding 1.4.11: Non-text Contrast

What the contrast ratio measures and why rounding matters

For each effective sRGB channel, set c = channel / 255. The tool uses c / 12.92 when c <= 0.04045, otherwise ((c + 0.055) / 1.055) ^ 2.4, to obtain its linear value. Relative luminance is L = 0.2126R + 0.7152G + 0.0722B using those linear R/G/B values. Contrast is (Llighter + 0.05) / (Ldarker + 0.05). The ratio ranges from 1:1 for equal luminance to 21:1 for black and white; it is not a difference between HEX strings or hue names.

The interface shows two decimal places using the selected language’s number formatting, but pass/fail compares the full computed ratio. A value just below 4.5 can display as 4.50:1 and still fail normal-text AA. Compare the report’s numeric ratio with its threshold rather than rounding the displayed value up. Effective background HEX is also rounded for display, while the calculation keeps composed fractional channels.

W3C WCAG 2.2: Criteria, large-scale text, relative luminance and contrast ratioW3C Understanding 1.4.3: Contrast (Minimum)

Large text: points, CSS pixels and the preview flag

WCAG’s large-scale definition includes 18-point text or 14-point bold text, with qualifications for equivalent CJK sizes and thin or unusual fonts. CSS absolute units give 96 pixels and 72 points per inch: 18 points corresponds to 24 CSS pixels, and 14 points to about 18.67 CSS pixels. Physical screen pixels and an image editor’s pixel-density setting are not interchangeable with these CSS sizes.

The preview starts at 16 CSS pixels with normal weight. It clamps Text size (px) to 10–72, and Bold text uses weight 700 rather than 400. Its large-text flag uses size at least 24, or bold size at least 18.6666666667. This is a preview rule, not automatic detection of the real font’s metrics or script-specific equivalent size. Judge the actual typography and content separately.

Large text: points, CSS pixels and the preview flag
Preview settingPreview classificationRatio change from size/weight alone
16 px, normalNormal textNone
24 px, normalLarge textNone
18.66 px, boldNormal text under this tool’s cutoffNone
18.67 px, boldLarge textNone

W3C WCAG 2.2: Criteria, large-scale text, relative luminance and contrast ratioW3C CSS Values and Units 4: Absolute lengths

Worked examples with opaque sRGB colors

Use the exact foreground/background values below with an opaque white canvas. Ratios in the table are the English two-decimal display; the flags come from the full calculation. The gray examples show how a small channel change can cross a threshold without producing a large-looking visual difference.

These are pair calculations, not recommended universal palettes. Changing one shared token can affect other elements, themes and states. Opaque black on white gives the maximum ratio, while equal white foreground/background gives 1:1. The default green pair reaches all five numeric thresholds, but its use in a real component still needs context.

Worked examples with opaque sRGB colors
Text colorBackground colorDisplayed ratioNormal AA / AAA
#000000#FFFFFF21.00:1Pass / Pass
#FFFFFF#FFFFFF1.00:1Fail / Fail
#777777#FFFFFF4.48:1Fail / Fail
#767676#FFFFFF4.54:1Pass / Fail
#294C39#FFFFFF9.60:1Pass / Pass

W3C WCAG 2.2: Criteria, large-scale text, relative luminance and contrast ratio

Transparency: compose the background first, then the text

Canvas behind transparency is an opaque HEX color picker. The tool first composes Background color over that canvas, then Text color over the effective background. Only after those two steps does it calculate relative luminance and contrast. Decimal alpha is retained; fractional composed channel values are not rounded before this calculation.

For half-transparent black on opaque white, the effective text channels are 127.5 and the displayed ratio is 3.98:1. With a half-transparent white background over black, the effective background becomes 127.5 and the same half-transparent black text becomes 63.75, giving 2.62:1. These changes come from the actual surface stack, not from font size.

Transparency: compose the background first, then the text
Layered exampleEffective background RGBEffective foreground RGBDisplayed ratio
rgba(0,0,0,0.5) on #FFFFFF, white canvas255,255,255127.5,127.5,127.53.98:1
rgba(0,0,0,0.5) on rgba(255,255,255,0.5), black canvas127.5,127.5,127.563.75,63.75,63.752.62:1

W3C Compositing and Blending Level 1: Simple alpha compositing

Swapping colors and choosing decimal or HEX alpha

Swap colors exchanges the two raw foreground/background entries and keeps the canvas. For opaque colors the luminance ratio is symmetric, so swapping preserves it. With transparency, the layer roles change and the ratio can change; test the swapped result rather than assuming the same score.

HEX alpha is an 8-bit value. For example, #0008 expands to #00000088 with alpha 136/255, which is different from decimal alpha 0.5 in rgba(0,0,0,0.5). Keep the representation required by your stylesheet. A rounded HEX representation of an alpha value or composed color is not necessarily an exact substitute for the original decimal input.

W3C CSS Color 4: Named colors, sRGB and alphaW3C Compositing and Blending Level 1: Simple alpha compositing

Supported color syntax and input quantization

The parser accepts 148 standard CSS named-color spellings plus transparent, case-insensitively; 3, 4, 6 or 8 HEX digits with an optional leading #; and numeric RGB/RGBA or HSL/HSLA functions. It supports comma forms and space/slash forms within its grammar. HSL saturation and lightness require percentages, and hue can use degrees, grads, radians or turns.

RGB channels and converted HSL channels are rounded to integer 8-bit sRGB values before composition, while decimal alpha remains a numeric fraction. Out-of-range channels or alpha are rejected instead of following every CSS clipping rule. Context-dependent names, currentcolor, custom-property expressions, calc(), relative colors and Lab/Oklab or wide-gamut functions are unsupported. Use the actual supported sRGB values rather than assuming this is a complete CSS evaluator.

Supported color syntax and input quantization
FormAccepted exampleUseful distinction
Named colorRebeccaPurpleCSS keyword, not a translated color description
HEX#294C39Four/eight digits also encode 8-bit alpha
Comma RGBArgba(0,0,0,0.5)Decimal alpha is retained
Space/slash RGBrgb(0 0 0 / 50%)Numeric channels and optional alpha
HSLhsl(120deg 100% 25%)Saturation/lightness are percentages; result is quantized sRGB

W3C CSS Color 4: Named colors, sRGB and alpha

Check the real background, typography and interaction states

A solid pair is a model of the colors you enter. Images, gradients, overlays, ancestor opacity, blend modes and filters can produce different relevant surfaces or rendered colors. Inspect the actual stylesheet and visual context, then evaluate the pairs that matter in each theme and state. The checker does not fetch a webpage, inspect its DOM or sample a background image.

Anti-aliasing can make glyph-edge pixels lighter than the intended text color. WCAG text guidance directs evaluation toward the underlying foreground/background colors rather than using a softened edge pixel as the text value. Still inspect readability with the real font and choose practical margin above a threshold where appropriate; a ratio alone does not evaluate all visual or interaction barriers.

W3C Understanding 1.4.3: Contrast (Minimum)W3C WCAG 2.2: Criteria, large-scale text, relative luminance and contrast ratio

Use the non-text row for the relevant adjacent colors

Success Criterion 1.4.11 concerns visual information needed to identify covered controls, states and graphical objects against their adjacent colors. A generic 3:1 row cannot choose those pairs for you. For a button, its label’s text contrast and the visual information identifying the component or state can involve different comparisons.

The criterion has context-dependent exceptions, including inactive components and certain unmodified user-agent or essential presentations. Focus indicators also require assessment under the applicable focus criteria; the tool’s nonTextAA flag is not a complete focus evaluation. Decide what visual information is required before treating an isolated numeric result as evidence.

W3C Understanding 1.4.11: Non-text ContrastW3C Understanding 2.4.13: Focus Appearance

Improve a failing pair and test the affected uses

Adjust the foreground, background or opacity deliberately and watch the result recalculate. Darkening a foreground on a light surface, lightening it on a dark surface, or reducing unwanted transparency can help, but check the actual result rather than relying on color names or HSL lightness alone. The tool reports your edits; it does not select an automatic replacement.

After choosing a passing pair, revisit the places where each token is used. A changed accent can improve one label while reducing contrast on another surface. Test body text, links and relevant states with their real backgrounds, and keep hierarchy and non-color cues meaningful.

  • Choose the row for the actual text size/weight or essential graphical information.
  • Check each relevant theme and state rather than only the default preview.
  • Record the resulting values and review them in the real component before applying a broad palette change.

Copy or download the full-precision JSON report

Copy report writes JSON to the clipboard when permission and browser support allow it. If copying fails, use Download report, which saves application/json as toolmellow-contrast.json. The report preserves the raw foreground, background and canvas entries; ratio; five thresholds; effective RGB values and result flags; preview size/bold/largeText; and the calculation method.

JSON keys and numeric values are technical data and stay in their machine-readable form across interface languages. Custom Preview text is not included in the exported object. Copy or download again after edits: a saved file or clipboard entry is a snapshot, and the page’s live update does not rewrite an earlier export. The JSON provides pair-calculation evidence, not a conformance certificate or an automated audit history.

Limits, invalid values and local state

Text color and Background color fields allow at most 200 UTF-16 units; Preview text allows 300. The canvas is an opaque native color control, and preview size is clamped to 10–72 CSS pixels. Invalid color syntax or unsupported ranges produce an error and suppress the report/export controls. Correct the input to restore the calculation; preview settings remain in page state.

Color parsing and ratio calculation run synchronously in this page, without sending the entered pair or preview text to a calculation server. Refreshing or leaving the page discards its in-memory state; downloaded reports and clipboard contents remain outside that state. The public website still makes ordinary hosting and analytics requests. Local calculation does not imply anonymity or zero infrastructure logging.

Embed the contrast checker with its backlink

Use the integration section below the workspace to copy or download the supplied localized HTML snippet. Paste it into a platform that permits the iframe and sizing script, and retain the visible backlink to the matching ToolMellow contrast-checker page. The provided credit link uses nofollow and noopener.

Test the embedded layout on a narrow screen and check clipboard behavior in the embedding context. The iframe retains the same live pair calculation, inputs and limitations. Its height messages size the workspace; they are not an API for scanning host-page styles or sending batches of contrast requests.

Common questions

How do I check color contrast?

Enter the actual Text color and Background color, choose the opaque canvas behind any transparency, then read the automatically updated ratio and appropriate threshold row. Use the real component’s colors and context.

What ratios do WCAG AA and AAA require for text?

The tool compares normal text with 4.5:1 for AA and 7:1 for AAA, and large text with 3:1 for AA and 4.5:1 for AAA. These are inclusive unrounded comparisons; determine the real criterion’s applicability separately.

Why can a displayed 4.50:1 fail?

The display has two decimal places, while pass/fail uses the full ratio. A computed value just below 4.5 may round to 4.50 on screen and still fail normal-text AA. Inspect the numeric JSON result.

What counts as large text in this preview?

Its flag uses at least 24 CSS pixels, or bold text at least 18.6666666667 CSS pixels. WCAG’s points/equivalent-size and font qualifications still need assessment for the actual typography.

Does Bold text increase the contrast ratio?

No. It changes preview weight and may change its normal/large classification, while the entered color pair determines the ratio. All five threshold rows remain visible.

How does transparent text affect contrast?

The background is composed over the selected opaque canvas first, then the text over that effective background. The ratio uses the resulting colors, retaining fractional composed channels.

Why does Swap colors change a transparent pair’s ratio?

It exchanges foreground/background roles while keeping the canvas. Transparency makes that composition order matter. Opaque pair ratios are symmetric; transparent swapped results need checking.

Are #0008 and half-transparent black identical?

No. #0008 has alpha 136/255, while decimal RGBA alpha 0.5 is exactly one half. HEX alpha is an 8-bit representation and may differ from a decimal-alpha input.

Can I enter any CSS color expression?

No. The supported parser covers named sRGB colors, HEX and numeric RGB/HSL forms. It rejects unsupported context-dependent expressions, variables, calculations, relative colors and wider color-space functions.

Does a pass prove the whole page meets WCAG?

No. It verifies a numeric comparison for the entered pair. Actual text size, adjacent colors, states and the other applicable accessibility criteria still require review; the checker does not scan a URL or DOM.

Can I use it for text on a gradient or image?

It calculates a solid pair rather than analyzing the image or gradient. Identify the relevant actual background colors and contexts separately before deciding what comparisons demonstrate the requirement.

Why do contrast calculators disagree?

Check the metric, parsed color values, RGB/HSL quantization, alpha and underlying canvas, composition order and rounding. This tool uses the WCAG 2.2 sRGB ratio, not APCA or a different contrast metric.

Does the JSON include my custom preview sentence?

No. It includes color inputs, ratio, thresholds, effective RGB/result flags, preview size/bold/largeText and method. Download report saves toolmellow-contrast.json; export again after changing inputs.

Can I embed the checker on my webpage?

Use its localized HTML snippet below the workspace, keep the visible ToolMellow backlink and test iframe/script/clipboard support. It remains a pair-calculation workspace rather than a host-page scanner or audit API.

Sources and further reading

Put it into practice.

Related guides