வார்ப்புரு:Greater color contrast ratio/doc
{{Documentation subpage}}
 &lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&gt;
 {{High-use|62535}}
 {{Lua|Module:Color contrast}}
 
 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, [http://www.w3.org/TR/WCAG20/#visual-audio-contrast 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 (&quot;khaki&quot;) or hextriplet with/without #-prefix (&quot;#F0E68C&quot;, &quot;F0E68C&quot;) {{legend inline|#F0E68C}}
 
 :{{para|1}} (required): background color
 :{{para|2}} first fontcolor. Optional, default = white (#FFFFFF)
 :{{para|3}} second fontcolor. Optional, default = black (#000000)
 
 ;The template returns the fontcolor with the greatest contrast:
 :background is {{legend inline|khaki |Khaki (#F0E68C)}}: &lt;nowiki&gt;{{Greater color contrast ratio|khaki|white|black}}&lt;/nowiki&gt; &amp;rarr; {{Greater color contrast ratio|khaki|white|black}}
 
 :background is {{legend inline|#4169E1|RoyalBlue (#4169E1)}}: &lt;nowiki&gt;{{Greater color contrast ratio|#4169E1|FFFFFF|000000}}&lt;/nowiki&gt; &amp;rarr;  {{Greater color contrast ratio|#4169E1|FFFFFF|000000}} ''(=white)''
 
 ;css text
 * {{para|css|y}} makes the template return css-ready text:
 ::{{legend inline|khaki |Khaki (#F0E68C)}}: &lt;code&gt;&lt;nowiki&gt;{{Greater color contrast ratio|khaki|white|black|&lt;/nowiki&gt;&lt;span style=&quot;background:yellow&quot;&gt;css=y&lt;/span&gt;}}&lt;/code&gt;
 ::&amp;rarr; &lt;span style=&quot;background:yellow&quot;&gt;{{mono|1={{Greater color contrast ratio|khaki|white|black|css=y}}}}&lt;/span&gt;
 
 ::'''Example 1''', {{legend inline|khaki |Khaki (#F0E68C)}}
 ::&lt;code&gt;&amp;lt;span style=&quot;&lt;nowiki&gt;font-size:110%; {{Greater color contrast ratio|khaki|white|black|css=y}}&lt;/nowiki&gt;&quot;&gt;Example text on khaki background.&amp;lt;/span&gt;&lt;/code&gt;
 ::&amp;rarr; &lt;code&gt;&amp;lt;span style=&quot;font-size:110%; &lt;nowiki&gt;background-color:khaki; color:black;&lt;/nowiki&gt;&quot;&gt;Example text on khaki background.&amp;lt;/span&gt;&lt;/code&gt;
 ::&amp;rarr; &lt;span style=&quot;font-size:110%; {{Greater color contrast ratio|khaki|white|black|css=y}}&quot;&gt;Example text on khaki background.&lt;/span&gt;
 
 ::'''Example 2''', {{legend inline|#4169E1|#4169E1 (RoyalBlue)}}
 ::&lt;code&gt;&amp;lt;span style=&quot;&lt;nowiki&gt;font-size:110%; {{Greater color contrast ratio|#4169E1|#ffffff|#000000|css=y}}&lt;/nowiki&gt;&quot;&gt;Example text on #4169E1 background.&amp;lt;/span&gt;&lt;/code&gt;
 ::&amp;rarr; &lt;code&gt;&amp;lt;span style=&quot;font-size:110%; &lt;nowiki&gt;background-color:#4169E1; color:#ffffff;&lt;/nowiki&gt;&quot;&gt;Example text on #4169E1 background.&amp;lt;/span&gt;&lt;/code&gt;
 ::&amp;rarr; &lt;span style=&quot;font-size:110%; {{Greater color contrast ratio|#4169E1|#ffffff|#000000|css=y}}&quot;&gt;Example text on #4169E1 background.&lt;/span&gt;
 
 ;bias
 * {{para|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 [[wp:accessibility|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
 * &lt;code&gt;&amp;lt;span style=&quot;background:navy; color:{{tlf|Greater color contrast ratio|navy|white|black}}&quot;&gt;Navy&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:navy; color:{{Greater color contrast ratio|navy|white|black}}&quot;&gt;Navy&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|navy|white|black|css{{=}}y}}&quot;&gt;Navy&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|navy|white|black|css=y}}&quot;&gt;Navy&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|navy|css{{=}}y}}&quot;&gt;Navy&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|navy|css=y}}&quot;&gt;Navy&lt;/span&gt;
 ;Red
 * &lt;code&gt;&amp;lt;span style=&quot;background:red; color:{{tlf|Greater color contrast ratio|red|white|black}}&quot;&gt;Red&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:red; color:{{Greater color contrast ratio|red|white|black}}&quot;&gt;Red&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|red|white|black|css{{=}}y}}&quot;&gt;Red&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|red|white|black|css=y}}&quot;&gt;Red&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|red|css{{=}}y}}&quot;&gt;Red&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|red|css=y}}&quot;&gt;Red&lt;/span&gt;
 ;White
 * &lt;code&gt;&amp;lt;span style=&quot;background:white; color:{{tlf|Greater color contrast ratio|white|white|black}}&quot;&gt;White&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:white; color:{{Greater color contrast ratio|white|white|black}}&quot;&gt;White&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|white|white|black|css{{=}}y}}&quot;&gt;White&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|white|white|black|css=y}}&quot;&gt;White&lt;/span&gt;
 ;Black
 * &lt;code&gt;&amp;lt;span style=&quot;background:black; color:{{tlf|Greater color contrast ratio|black|white|black}}&quot;&gt;Black&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:black; color:{{Greater color contrast ratio|black|white|black}}&quot;&gt;Black&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|black|white|black|css{{=}}y}}&quot;&gt;Black&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|black|white|black|css=y}}&quot;&gt;Black&lt;/span&gt;
 ;&lt;nowiki&gt;#&lt;/nowiki&gt;005500
 * &lt;code&gt;&amp;lt;span style=&quot;background:#005500; color:{{tlf|Greater color contrast ratio|#005500|#FFFFFF|#000000}}&quot;&gt;#005500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:#005500; color:{{Greater color contrast ratio|#005500|#FFFFFF|#000000}}&quot;&gt;#005500&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|#005500|#FFFFFF|#000000|css{{=}}y}}&quot;&gt;#005500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|#005500|#FFFFFF|#000000|css=y}}&quot;&gt;#005500&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;background:#005500; color:#{{tlf|Greater color contrast ratio|005500|FFFFFF|000000}}&quot;&gt;005500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:#005500; color:#{{Greater color contrast ratio|005500|FFFFFF|000000}}&quot;&gt;005500&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|005500|FFFFFF|000000|css={{y}}}}&quot;&gt;005500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|005500|FFFFFF|000000|css=y}}&quot;&gt;005500&lt;/span&gt;
 ;CC5500
 * &lt;code&gt;&amp;lt;span style=&quot;background:#CC5500; color:#{{tlf|Greater color contrast ratio|CC5500|FFFFFF|000000}}&quot;&gt;CC5500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:#CC5500; color:#{{Greater color contrast ratio|CC5500|FFFFFF|000000}}&quot;&gt;CC5500&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|CC5500|FFFFFF|000000|css{{=}}y}}&quot;&gt;CC5500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|CC5500|FFFFFF|000000|css=y}}&quot;&gt;CC5500&lt;/span&gt;
 ;CC5500, {{para|bias|1}}
 * &lt;code&gt;&amp;lt;span style=&quot;background:#CC5500; color:#{{tlf|Greater color contrast ratio|CC5500|FFFFFF|000000|bias{{=}}1}}&quot;&gt;CC5500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:#CC5500; color:#{{Greater color contrast ratio|CC5500|FFFFFF|000000|bias=1}}&quot;&gt;CC5500&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|CC5500|FFFFFF|000000|bias{{=}}1|css{{=}}y}}&quot;&gt;CC5500&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|CC5500|FFFFFF|000000|bias=1|css=y}}&quot;&gt;CC5500&lt;/span&gt;
 ;error
 * &lt;code&gt;&amp;lt;span style=&quot;background:Not a color; color:#{{tlf|Greater color contrast ratio|Not a color|FFFFFF|000000}}&quot;&gt;Not a color&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;background:Not a color; color:#{{Greater color contrast ratio|Not a color|FFFFFF|000000}}&quot;&gt;Not a color&lt;/span&gt;
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|Not a color|FFFFFF|000000|css{{=}}y}}&quot;&gt;Not a color&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|Not a color|FFFFFF|000000|css=y}}&quot;&gt;Not a color&lt;/span&gt;
 ::(returns &lt;code&gt;background-color:Not a color; color:;&lt;/code&gt;, and so no color is set; defaults to black-on-white.)
 
 * &lt;code&gt;&amp;lt;span style=&quot;{{tlf|Greater color contrast ratio|Navy|Not a color|000000|css{{=}}y}}&quot;&gt;Not a color&lt;/span&amp;gt;&lt;/code&gt; &amp;rarr; &lt;span style=&quot;{{Greater color contrast ratio|Navy|Not a color|000000|css=y}}&quot;&gt;Not a color&lt;/span&gt;
 ::(returns &lt;code&gt;background-color:Navy; color:;&lt;/code&gt;, and so no ''fontcolor'' is set; defaults to black. The template did not function.)
 
 == See also ==
 * {{tl|Ensure AAA contrast ratio}}
 * {{tl|Ensure AA contrast ratio}}
 * {{section link|Template:Color contrast conformance|HTML colors}}
 * {{section link|Wikipedia:Manual of Style/Accessibility|Color}}
 
 &lt;includeonly&gt;{{Sandbox other||
 &lt;!-- Categories below this line, please; interwikis at Wikidata --&gt;
 [[Category:Color conversion templates]]