Skip to content

[css-color-5] color-mix() algorithm requires division by zero #14013

Closed

Description

@weinig

For the case of color-mix(in srgb, red 0%, blue 0%, green 100%), the color-mix() result calculation requires division by zero.

The issue happens in the first iteration of step 4.2.2 calculating (b’s percentage) / combined percentage). In the first iteration, a and b will be [red 0%] and [blue 0%], with a combined percentage of 0%.

My proposal would be to change the text of step 4.2.2, replacing:

"...with a progress percentage equal to (b’s percentage) / combined percentage)."

with

"with a progress percentage equal to (b’s percentage) / combined percentage) if combined percentage is greater than 0, and 0.5 otherwise."

(or something to that effect).

cc @svgeesus

Activity

  1. self-assigned this
    on Jun 4, 2026
  2. yisibl commented on Sep 2, 2026

    @yisibl
    Contributor

    @svgeesus @weinig I think the conclusion in Example 5(8195d37) needs to be revised; the description of color-mix(in oklch, teal 0%, olive 0%) as resulting in “transparent black” is no longer correct.

    In this example, both percentages are zero, so their sum is also zero:
    color-mix(in oklch, teal 0%, olive 0%);
    Thus, the result is transparent black, in the oklch color space:
    oklch(0% 0 none / 0)
    https://drafts.csswg.org/css-color-5/#ex-mix-zero-sum

    The WPT has been fixed in web-platform-tests/wpt@5942b88

  3. svgeesus commented on Sep 2, 2026

    @svgeesus
    Collaborator

    @yisibl to guard against this sort of thing in future (and because I have wanted such a tool for a while) behold

    color-mix() step by step

    which has now validated all the examples in the spec (and found a couple of errors).

    It computes ΔE between its own result and the browser result, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions