Template:Greater color contrast ratio/doc

This template determines the pair of colors with the larger contrast ratio: color1/color2 or color1/color3. This is useful for selecting a foreground/background color pair. For accessibility, WCAG 2.0 AA guidelines require a contrast ratio of 3 or larger for large text, and 4.5 or larger for normal sized text.

In the default mode, color2 and color3 are white and black, and the selected color pair will always have a contrast ratio greater than 4.58.

Parameters
A color input can be by name ("khaki") or hextriplet with/without #-prefix ("#F0E68C", "F0E68C")


 * 1 (required): background color
 * 2 first fontcolor. Optional, default = white (#FFFFFF)
 * 3 second fontcolor. Optional, default = black (#000000)


 * The template returns the fontcolor with the greatest contrast:
 * background is : &rarr;


 * background is : &rarr;   (=white)


 * css text
 * y makes the template return css-ready text:
 * &rarr;
 * &rarr;


 * Example 1,
 * &rarr;
 * &rarr; Example text on khaki background.
 * &rarr; Example text on khaki background.


 * Example 2,
 * &rarr;
 * &rarr; Example text on #4169E1 background.
 * &rarr; Example text on #4169E1 background.


 * bias
 * number: reduces contrast-check. A bias of 1.25, reduces the possible minimum to 4.0, which may not meet accessibility standards.
 * This parameter should be used with caution to ensure accessibility. As stated above, when used without a bias, and with color2 and color3 equal to white and black, the selected color pair will always have a contrast ratio greater than 4.58.

Examples

 * Navy
 * &rarr; Navy
 * &rarr; Navy
 * &rarr; Navy
 * Red
 * &rarr; Red
 * &rarr; Red
 * &rarr; Red
 * White
 * &rarr; White
 * &rarr; White
 * Black
 * &rarr; Black
 * &rarr; Black
 * # 005500
 * &rarr; #005500
 * &rarr; #005500
 * &rarr; <span style="background:#005500; color:#">005500
 * &rarr; <span style="">005500
 * CC5500
 * &rarr; <span style="background:#CC5500; color:#">CC5500
 * &rarr; <span style="">CC5500
 * CC5500, 1
 * &rarr; <span style="background:#CC5500; color:#">CC5500
 * &rarr; <span style="">CC5500
 * error
 * &rarr; <span style="background:Not a color; color:#">Not a color
 * &rarr; <span style="">Not a color
 * (returns, and so no color is set; defaults to black-on-white.)


 * &rarr; <span style="">Not a color
 * (returns, and so no fontcolor is set; defaults to black. The template did not function.)