HundredVisionsGuy / webcode-tk

Other
0 stars 0 forks source link

Adjust Color Contrast Checker to account for base font size. #21

Closed HundredVisionsGuy closed 2 weeks ago

HundredVisionsGuy commented 4 months ago

When determining whether an element meets the color contrast goals as defined in the WebAim Contrast Checker, we need to only measure a goal based on whether the element in the context of the browser (having styles applied or not) as well as whether we wish to meet it at a AA or AAA level.

According to the WebAim Contrast Checker website,

Large text is defined as 14 point (typically 18.66px) and bold or larger, or 18 point (typically 24px) or larger.

By default, the base font-size is 16px. In order for a p or anything other than an h1-h3 tag to be considered large, it would have to be enlarged by 150%. There are some different ways it could be applied.

Since all h tags are by default bold, without any size adjustment, only h1, h2, and h3 tags are bold and large enough to qualify as large in size (NOTE: the h3 tag by default is 18.72px in size).

My suggestion is to add to the cascade_tools' CSSAppliedTree a search for any changes to file size as well as what the computed size should be (this would be fun considering the cascade and inheritance). Here are my initial thoughts:

NOTES about em v rem values:

HundredVisionsGuy commented 3 months ago

Issues remaining:

HundredVisionsGuy commented 3 weeks ago

All color tools related to alpha blending and gradients are in place. We just need to integrate them into the cascade tool..

On the bold front (see first check box above), it turns out that most browsers will compute the font-weight to 700. According to the WebAIM: Contrast Checker,

In CSS, bold text typically has font-weight:bold, or font-weight:700 or greater.

Next steps: Add a check for bold or not and apply to inheritance using these steps: