Module:Color contrast/doc
This is the documentation page for Module:Color contrast
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This Lua module is used on approximately 466,000 pages, or roughly 19563% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This module depends on the following other modules: |
This module is used primarily by
- {{[[Template:Color contrast ratio
|Color contrast ratio ]]}}
- {{[[Template:RGBColorToLum
|RGBColorToLum ]]}}
- {{[[Template:Color contrast conformance
|Color contrast conformance ]]}}
- {{[[Template:Ensure AAA contrast ratio
|Ensure AAA contrast ratio ]]}}
- {{[[Template:Ensure AA contrast ratio
|Ensure AA contrast ratio ]]}}
- {{[[Template:Greater color contrast ratio
|Greater color contrast ratio ]]}} It is also used for tracking within
and for documentation in
The formulas used are stated in WCAG 2.x specifications. WCAG is the main guideline for creating accessible interfaces on the web.
Usage
demeseTo use this module, you may use one of the above listed templates or invoke the module directly
- To compute relative luminescence:
{{ColorToLum|color}}
or{{#invoke:Color contrast|lum|color}}
- To compute a contrast ratio between two colors:
{{Color contrast ratio|color1|color2|error=?}}
or{{#invoke:Color contrast|ratio|color1|color2|error=?}}
- To determine which of two colors (color2a and color2b) has the greater contrast ratio with a particular color (color1):
{{Greater color contrast ratio|color1|color2a|color2b}}
or{{#invoke:Color contrast|greatercontrast|color1|color2a|color2b}}
- To compute the contrast ratio between the background and text colors specified in a css style string:
{{#invoke:Color contrast|styleratio|css style statement string|default background color|default text color}}