Free · No sign-up Client-side

WEB & FRONT-END · CLIENT-SIDE MATH

Relative Luminance Calculator

WEB & FRONT-END · CLIENT-SIDE MATH October 2026 10 min read

Computes WCAG relative luminance from an sRGB colour and its contrast against white and black. Free, instant and entirely client-side.

Relative luminance ranges from 0 (black) to 1 (white).

Computes WCAG relative luminance from an sRGB colour and its contrast against white and black.

WEB & FRONT-ENDClient-sideFreeWorked examples
Good LCP threshold
≤2.5 s
Source: web.dev / Core Web Vitals
Good INP threshold
≤200 ms
Source: web.dev / Core Web Vitals
Good CLS threshold
≤0.1
Source: web.dev / Core Web Vitals
Default root font size
16 px
Source: Browser default

Quick answer

Computes WCAG relative luminance from an sRGB colour and its contrast against white and black. The calculator applies Y = 0.2126 R + 0.7152 G + 0.0722 B, with each channel linearised. and shows every intermediate value.

On this page
  1. 1Quick Answer
  2. 2Interactive Calculator
  3. 3Relative Luminance Calculator: CSS & Layout Breakdown
  4. 4Key Takeaways
  5. 5Web Development & Front-End: Reference Numbers
  6. 6Relative Luminance Calculator: Implementation Options Compared
  7. 7Reference Tables
  8. 8Formulas & How to Use
  9. 9Worked Examples
  10. 10Advanced Web Development & Front-End Guide: Relative Luminance Calculator
  11. 11Language Playbooks
  12. 12Glossary
  13. 13Mistakes & Pro Tips
  14. 14Use Cases
  15. 15Related Calculators
  16. 16Long-Tail Answers
  17. 17FAQs (27)
  18. 18References

Interactive Calculator

Enter a value — every result updates instantly, in your browser. Free forever, no sign-up.

Private Exact math

Relative Luminance Calculator

Every input is evaluated locally in your browser with deterministic, auditable arithmetic.

Runs in your browser
CSS color

Live result

0.117 relative luminance

Y 0.117white contrast 6.3:1

Relative luminance

0.117

Contrast vs white

6.29 : 1

Contrast vs black

3.34 : 1

Perceived brightness

103.54

Relative Luminance Calculator: CSS & Layout Breakdown

Converted units, resolved values and the assumptions behind the layout math.

Calculated values and metric details
Relative luminance
0.117
Contrast vs white
6.29 : 1
Contrast vs black
3.34 : 1
Perceived brightness
103.54
Channel linear R
0.0782
Channel linear G
0.0612
Channel linear B
0.7835
Luminance band
Dark

Step-by-step calculation

  1. 1sRGB channels: R 79, G 70, B 229.
  2. 2Linearise each channel: c ≤ 0.03928 ? c/12.92 : ((c+0.055)/1.055)^2.4.
  3. 3Y = 0.2126 × 0.0782 + 0.7152 × 0.0612 + 0.0722 × 0.7835 = 0.117.
  4. 4Relative luminance drives WCAG contrast; it is not the same as perceptual lightness (L*), which is more uniform to the eye.

Key Takeaways

The 30-second version — the exact answers Google loves to feature.

  • 1Relative luminance ranges from 0 (black) to 1 (white).
  • 2It is not the same as HSL lightness or perceptual L*.
  • 3The green channel contributes most to perceived luminance.
  • 4The result is deterministic: the same inputs and options produce the same output.
  • 5Use the breakdown to verify the headline number before acting on it.

Web Development & Front-End: Reference Numbers

Useful thresholds and rules of thumb for interpreting the result.

Good LCP threshold
≤2.5 s
Source: web.dev / Core Web Vitals
Good INP threshold
≤200 ms
Source: web.dev / Core Web Vitals
Good CLS threshold
≤0.1
Source: web.dev / Core Web Vitals
Default root font size
16 px
Source: Browser default

Relative Luminance Calculator: Implementation Options Compared

Choose the workflow that matches your accuracy, automation and review needs.

Design handoff

Best for: Translating a visual spec into CSS values

  • Method: Convert units, ratios and color values once, then store them as design tokens.
  • Precision: Exact for the chosen base; depends on the root and parent font sizes.
  • Safeguards: Document the base font size and check the result in the browser.
Recommended

Component implementation

Best for: Building a reusable UI component

  • Method: Use relative units and container-aware layout, then test at narrow and wide widths.
  • Precision: Approximate until measured in the real layout.
  • Safeguards: Test zoom, long content and reduced-motion settings.

Performance audit

Best for: Diagnosing layout shift, payload and rendering issues

  • Method: Measure field data and lab traces, then compare against Core Web Vitals thresholds.
  • Precision: Field data is realistic; lab data is reproducible but synthetic.
  • Safeguards: Segment by device and connection type before optimising.

Quick Reference Tables

Widths, ranges, boundary values and language types — the lookup tables you will come back to.

Core Web Vitals thresholds

MetricGoodNeeds improvementPoor
LCP≤2.5 s2.5–4.0 s>4.0 s
INP≤200 ms200–500 ms>500 ms
CLS≤0.10.1–0.25>0.25

Relative Luminance Calculator: Input Reference

Documented defaults and expected formats for every input on this page.

InputTypeDefaultWhat it controls
CSS colorText#4f46e5Value used by the relative luminance calculator.

Formulas & How to Use This Calculator

Core relationship

Y = 0.2126 R + 0.7152 G + 0.0722 B, with each channel linearised.

Verification checklist

1. Confirm the base font size or viewport used by the calculation. 2. Recompute the conversion by hand. 3. Inspect the computed value in DevTools. 4. Test at 200% zoom and a narrow viewport.

How to use — step by step

  1. Enter the CSS values or measurements that relative luminance calculator needs.
  2. Set the root, parent or viewport base that the calculation depends on.
  3. Read the converted value and the generated CSS where provided.
  4. Check the result in the browser at the target viewport and zoom level.
  5. Test a long label, a narrow container and a user-increased font size.
  6. Store the final value as a documented token or component rule.

Worked Examples

Real numbers and raw bits, fully worked — copy the pattern for your own code or protocol.

Default scenario

Inputs

CSS color: #4f46e5

Math

sRGB channels: R 79, G 70, B 229. Linearise each channel: c ≤ 0.03928 ? c/12.92 : ((c+0.055)/1.055)^2.4.

Result

0.117 relative luminance — Relative luminance: 0.117; Contrast vs white: 6.29 : 1

Alternate inputs

Inputs

CSS color: #2563eb

Math

sRGB channels: R 37, G 99, B 235. Linearise each channel: c ≤ 0.03928 ? c/12.92 : ((c+0.055)/1.055)^2.4.

Result

0.1532 relative luminance — Relative luminance: 0.1532; Contrast vs white: 5.17 : 1

Boundary inputs

Inputs

CSS color: #f97316

Math

sRGB channels: R 249, G 115, B 22. Linearise each channel: c ≤ 0.03928 ? c/12.92 : ((c+0.055)/1.055)^2.4.

Result

0.3246 relative luminance — Relative luminance: 0.3246; Contrast vs white: 2.8 : 1

Advanced Web Development & Front-End Guide: Relative Luminance Calculator

Relative Luminance Calculator explained beyond the formula — assumptions, edge cases, thresholds and the workflows professionals use.

CSS units and the formatting context

A CSS length is resolved relative to a context. px is absolute in CSS terms but scaled by the device pixel ratio and browser zoom. rem is relative to the root font size, em to the element’s inherited font size, and percentages to the containing block or another property-specific base. Relative Luminance Calculator makes that base explicit. When a value looks wrong in the browser, inspect the computed styles first; the declared value is only part of the story.

How the calculation works

Computes WCAG relative luminance from an sRGB colour and its contrast against white and black. The core relationship is: Y = 0.2126 R + 0.7152 G + 0.0722 B, with each channel linearised. Use the result as a starting point, then confirm it in the browser at the actual viewport, font size and zoom level. Design tools often round values; production CSS should keep enough precision to avoid cumulative layout drift, especially in grids and nested components.

Responsive layout and content-driven breakpoints

Device-specific breakpoints age quickly. Better breakpoints come from where the content actually breaks: a card grid that becomes cramped, a navigation bar that wraps, or a table that overflows. Resize the viewport gradually and add a breakpoint at the first failure. Use modern layout primitives such as flex-wrap, grid auto-fit and container queries to reduce the number of explicit breakpoints.

Accessibility and user preferences

Users can change the browser’s default font size, zoom the page, or request reduced motion and higher contrast. rem-based typography respects the first; fixed px does not. Avoid locking text into viewport units without a clamp, and never disable zoom. Check color contrast against the final rendered colors, including opacity and gradients. Accessibility is part of correctness, not a separate polish step.

Layout shift and reserved space

Cumulative Layout Shift measures unexpected movement of visible content. Images without dimensions, late-loading fonts, injected banners and ads are common causes. Reserve space with aspect-ratio, width and height attributes, or a min-height placeholder. For relative luminance calculator, check whether the computed size changes after fonts or images load. Stable geometry is often more valuable than a tiny visual tweak.

Colors, contrast and perception

Hex, RGB and HSL are different representations of the same color model, not different colors. Alpha compositing blends a translucent color with its backdrop, so the final contrast depends on what is underneath. Relative luminance is calculated after linearising sRGB channels; a mid-gray can have far less luminance than its numeric value suggests. Always test the composited result, not only the declared color.

Performance budgets for CSS and images

Stylesheets and images compete for bandwidth and main-thread time. A large CSS bundle delays rendering; an oversized hero image delays Largest Contentful Paint. Set budgets for compressed transfer size, image dimensions and the number of render-blocking requests. Generate responsive image variants and use modern formats with fallbacks. Measure on a mid-range mobile device, not only on a fast desktop.

Testing across browsers and input modes

A value that works in one browser may behave differently in another because of default styles, scrollbar width, font metrics or support for newer units. Test the actual interaction with keyboard, touch and zoom. Use feature queries for progressive enhancement rather than browser sniffing. For relative luminance calculator, keep a small visual regression suite around the component so a future CSS change cannot silently break the layout.

Language & Platform Playbooks

The same bit pattern behaves differently in every language. Here is how to adapt the conversion safely.

Design tokens

Compute relative luminance calculator once, then store the result as a named token rather than scattering magic numbers. Document the base font size, viewport assumptions and fallback. Tokens make a global change reviewable and keep components consistent across the design system.

Component CSS

Apply the value inside the component and test it with long labels, narrow containers and 200% zoom. Prefer relative units for type and spacing, and use minmax(0, 1fr) or min-width: 0 where content could force overflow. Confirm the computed value in DevTools rather than trusting the source.

Responsive QA

Check relative luminance calculator at the smallest supported width, a typical tablet width and a wide desktop. Test with the browser’s default font size increased, with a long translation, and with images blocked. Add a regression screenshot for the breakpoint where the layout changes.

Performance audit

Measure LCP, INP and CLS in the field if possible, then reproduce the slowest case in the lab. Use the result from relative luminance calculator to set a budget, and verify the compressed transfer size. Optimise the largest contributor first rather than shaving many tiny assets.

Glossary: Key Terms Explained

rem
A length unit relative to the root element’s computed font size.
em
A length unit relative to the current element’s inherited font size.
Viewport unit
A length unit based on the viewport width, height or their smaller/larger dimension.
Specificity
The weight of a CSS selector that determines which competing declaration wins.
Aspect ratio
The proportional relationship between width and height, often reserved before media loads.
Layout shift
Unexpected movement of visible content as resources load or fonts swap.

Common Mistakes & Pro Tips

Mistakes that break conversions

  • Using HSL lightness as a substitute for luminance.
  • Forgetting to linearise the sRGB channels before weighting.
  • Assuming 1rem always equals 16px regardless of user settings.
  • Using viewport units for body text without a clamp, making it unreadable at extremes.
  • Forgetting that percentages resolve against different bases depending on the property.
  • Checking contrast on the declared color instead of the composited result.

Pro tips for production code

  • Use luminance to decide whether text should be light or dark.
  • Still verify the final contrast ratio, not just the luminance value.
  • Use rem for global type and spacing, em for component-local scaling.
  • Reserve image space with aspect-ratio or explicit dimensions.
  • Test at 200% zoom and with a larger default font size.
  • Prefer content-driven breakpoints over device-specific ones.

Who Should Use This Calculator?

  • ▸ Choosing an automatic text colour for a dynamic background.
  • ▸ Understanding WCAG contrast calculations.
  • ▸ Converting a design spec to CSS.
  • ▸ Auditing responsive typography.
  • ▸ Fixing layout shift and contrast issues.
  • ▸ Building a design-token scale.

Related Programming Calculators

Keep going — every tool below links directly into this workflow.

People Also Search For

Tap a long-tail question to jump to the matching FAQ answer.

Frequently Asked Questions (27)

Long-tail answers: each question targets a real Google search about relative luminance calculator — click to expand.

Showing 27 of 27 answers.

Why is relative luminance not just the average of RGB?
Human vision is more sensitive to green than to red or blue, and sRGB values are gamma-encoded. WCAG first linearises each channel and then weights them 0.2126, 0.7152 and 0.0722. A pure green appears much brighter than a pure blue with the same numeric RGB values, and the luminance formula reflects that.
Which browsers support relative luminance calculator?
Support is broad for the core CSS features used here, but newer units and functions can lag in older browsers. Check a compatibility table for the exact feature and provide a sensible fallback. For relative luminance calculator, test the fallback path as well as the modern path; a value that silently disappears is worse than a slightly different layout.
Should I use px, rem or em for relative luminance calculator?
Use rem for global typography and spacing, em for component-local scaling, and px for borders, shadows and fine visual details. Percentages depend on the property and containing block, so verify them in context. The right choice is the one that scales correctly for the user and remains predictable for the maintainer.
How does relative luminance calculator affect accessibility?
Accessibility depends on whether the value respects user font settings, zoom, contrast and reduced-motion preferences. Relative units generally scale better than fixed pixels. For relative luminance calculator, test at 200% zoom, with a larger default font size and with a screen reader, and confirm that the layout does not clip or overlap.
Why does relative luminance calculator look different in my browser?
Default styles, font metrics, scrollbar width, device pixel ratio and browser zoom all affect the computed layout. A design tool may also round values differently. Inspect the computed styles and the containing block dimensions rather than comparing declared values. Test the same viewport in at least two engines before concluding that the CSS is wrong.
Can I use relative luminance calculator with a design system?
Yes, but convert the value into a named token or a component rule rather than copying a magic number. Document the base, the intended use and any fallback. If the token changes, every consumer should update consistently. Keep visual regression tests around the components that depend on it.
How does relative luminance calculator relate to Core Web Vitals?
It can affect LCP, INP or CLS depending on what it controls. Image dimensions and reserved aspect ratios prevent layout shift; font sizing affects text rendering and reflow; large gradients and images add payload. Measure the actual metric in the field, then use the calculation to explain or fix the largest contributor.
What does the Relative Luminance Calculator calculate?
Computes WCAG relative luminance from an sRGB colour and its contrast against white and black. It shows the primary result first, then the supporting values and the steps used to reach it. Everything runs locally in your browser, so you can experiment without sending data to a server.
How do I use the Relative Luminance Calculator?
Enter the values or paste the data in the input panel. The result updates automatically as you type. Use the reset button to return to the documented defaults, then change one input at a time to see which value moves the result.
What formula does the Relative Luminance Calculator use?
Y = 0.2126 R + 0.7152 G + 0.0722 B, with each channel linearised. The page displays the substitution and the intermediate values so you can verify the arithmetic. If you get a different answer elsewhere, compare the definitions and units before assuming either tool is wrong.
Is the Relative Luminance Calculator accurate?
The arithmetic is deterministic and follows the formula shown. Real-world accuracy depends on the assumptions behind the inputs, such as whether a measurement is an average or a peak, whether text is UTF-8, or whether a regex engine backtracks. Use the result as a model and validate critical decisions against measured data.
Is the Relative Luminance Calculator free and private?
Yes. The calculator is free, requires no account, and performs the computation in your browser. Values are not uploaded by the calculator itself. As with any web page, the site may load standard analytics; avoid pasting secrets, production tokens or personal data into any online tool.
Does the Relative Luminance Calculator work offline?
After the page has loaded, the calculation runs locally and does not need a network request. You can keep the tab open while working offline. A first visit still requires loading the page and its assets from the site.
What units does the Relative Luminance Calculator use?
The input labels state the expected unit. Where multiple units are supported, choose the matching option before entering a value. Mixing milliseconds and seconds, bytes and kilobytes, or characters and UTF-8 bytes is the most common source of results that are off by a factor of 1,000 or more.
Can I use the Relative Luminance Calculator in CI or automation?
The formulas and thresholds can be implemented in a script or linter, but this page is an interactive tool, not a hosted API. Reproduce the calculation in your own code with pinned library versions, add tests for boundary cases, and keep the browser page for exploration and explanation.
Why do my results differ from another tool?
Different tools may count different units, use a different default, include or exclude generated code, or apply a different encoding. Check the scope and units first, then reproduce the calculation by hand. For relative luminance calculator, the definitions section on this page lists the assumptions used.
How do I verify the Relative Luminance Calculator result by hand?
Start with the smallest possible input, apply the formula one step at a time, and compare each intermediate value with the breakdown. Then test a boundary value such as zero, one, a maximum, or an empty input. If the headline and the rows disagree, the unit or scope is usually the cause.
What is a common mistake when using the Relative Luminance Calculator?
Using HSL lightness as a substitute for luminance. Read the input help and the breakdown before acting on the headline number.
Does the Relative Luminance Calculator handle large inputs?
It is designed for interactive use, not for multi-gigabyte files or unbounded streams. Very large inputs can make the browser slow or hit memory limits. For production-scale data, use a command-line tool, a streaming parser or a server-side job, and apply the same formula with appropriate limits.
How do I share a Relative Luminance Calculator result?
Copy the headline value and the relevant input rows, and include the units and assumptions. If you need to reproduce the result later, record the date, tool version and any options that affect the output. A screenshot alone is usually not enough to reconstruct the calculation.
Which related calculators should I use next?
The related links below the calculator point to tools that share inputs or concepts. Start with the one that covers the next step in your workflow, such as converting units, checking a threshold or estimating the downstream cost. Each page follows the same structure so you can move between them quickly.
Can the Relative Luminance Calculator handle zero or empty values?
Most calculations handle zero explicitly and show a clear error when a required value is missing or a denominator is zero. Read the warning or error message rather than assuming the result is valid. For ratios and averages, a zero denominator is undefined, not zero.
Where can I learn more about the method behind the Relative Luminance Calculator?
The references section lists authoritative specifications, standards and practitioner guides. Start with the specification for exact definitions, then use the practitioner resources for examples and trade-offs. The advanced education section on this page explains the assumptions and edge cases in more depth.
Does the Relative Luminance Calculator send my inputs to a server?
No. The calculation is performed entirely in your browser and the input values are not submitted by the calculator. The page itself is served like any other website, so standard hosting and analytics requests may still occur. Do not paste secrets, access tokens or personal data into any online tool.
Can I use the Relative Luminance Calculator for production decisions?
Use it to explore, explain and sanity-check a decision, then confirm critical values with measurements or an authoritative implementation. Production decisions should record the inputs, assumptions, tool version and date. Where money, security or safety is involved, add an independent review rather than relying on a single estimate.
What should I check before trusting the Relative Luminance Calculator result?
Check the units, the scope of what is counted, and whether the inputs describe an average, a peak or a worst case. Then reproduce one value by hand using the breakdown. If the result drives a threshold or budget, add a safety margin and test a boundary case such as zero, an empty value or a maximum.
How often should I re-run the Relative Luminance Calculator?
Re-run it whenever an input changes: code size, traffic, latency, prices, team capacity or the data format. For ongoing work, review the result on the same cadence as the metric it supports, such as each sprint, release or capacity review. Trends over consistent measurements are more useful than a single snapshot.

Resources & Authoritative References

Further reading

Authoritative sources

Was this calculator helpful?

Last updated: October 2026 · Free forever · No sign-up · Part of Programming Calculators at Atlascalcs.com · All math runs in your browser