Skip to content

Incorrect comparison in color-contrast function (should be >= instead of >) #41543

@bogdanfurs

Description

@bogdanfurs

According to the WCAG 2.1 Success Criterion 1.4.3 Contrast (Minimum) the visual presentation of text and images of text has a contrast ratio of at least 4.5:1 (i.e., >= 4.5), not strictly greater than (>).

However, in Bootstrap’s SCSS function color-contrast, the comparison is currently implemented as strictly greater than:
@if $contrast-ratio > $min-contrast-ratio {

This excludes cases exactly equal to the WCAG minimum requirement, which could incorrectly trigger warnings or lead to unnecessary manual adjustments.

Proposed Fix:
Update the conditional to correctly reflect the WCAG standard:
@if $contrast-ratio >= $min-contrast-ratio {

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    To analyze

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions