Template:Color: Difference between revisions
Dat Hack3r (talk | contribs) m Remove extra newline at the end of the template |
Dat Hack3r (talk | contribs) m Remove extra newlines for the last time, hopefully |
||
| Line 1: | Line 1: | ||
<templatestyles src="Color/styles.css" /> | <templatestyles src="Color/styles.css" /><span class="color-box" style="background-color: #{{#ifeq:{{Greater color contrast ratio|{{#if:{{{1|}}}|{{{1}}}|{{{color|#000000}}}}}}}|#000000|444444|eeeeee}};"><span class="color-text" style="color: {{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}};{{#ifeq:{{Greater color contrast ratio|{{#if:{{{1|}}}|{{{1}}}|{{{color|#000000}}}}}}}|#000000|background-color: black;}}">{{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}}</span><span class="color-fill" style="background-color: {{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}};"></span></span><noinclude> | ||
<span class="color-box" style="background-color: #{{#ifeq:{{Greater color contrast ratio|{{#if:{{{1|}}}|{{{1}}}|{{{color|#000000}}}}}}}|#000000|444444|eeeeee}};"> | |||
<span class="color-text" style="color: {{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}};{{#ifeq:{{Greater color contrast ratio|{{#if:{{{1|}}}|{{{1}}}|{{{color|#000000}}}}}}}|#000000|background-color: black;}}">{{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}}</span> | |||
<span class="color-fill" style="background-color: {{#if:{{{1|}}}|{{#tag:nowiki|{{{1}}}}}|{{#tag:nowiki|{{{color|#000000}}}}}}};"></span> | |||
</span><noinclude> | |||
{{Documentation}} | {{Documentation}} | ||
</noinclude> | </noinclude> | ||
Latest revision as of 00:57, 31 January 2026
#000000
| This template is a high priority for maintenance as it is original to the OWOT Wiki and used in articles. As such, this template may contain bugs and it should be a top priority of template maintainers to quickly fix any issues that arise with it. Discuss breaking changes on the talk page before implementing them. |
{{Color}} generates a stylized color box that displays a color name or value in that color alongside a matching swatch. The color can be specified as either a CSS color name (e.g., royalblue) or a hex triplet with the # prefix (e.g., #4169e1). The color value can be passed either as the first positional parameter or via |color=. The color box automatically chooses either a light or dark background to maximize contrast, ensuring a contrast ratio greater than 4.58 and exceeding the WCAG 2.2 AA minimum of at least 4.5 for normal-sized text.
{{color|royalblue}}→- royalblue
{{color|#4169e1}}→- #4169e1
{{color|khaki}}→- khaki
{{color|#f0e68c}}→- #f0e68c
{{color|color=royalblue}}→- royalblue
{{color|color=#4169e1}}→- #4169e1
{{color|color=khaki}}→- khaki
{{color|color=#f0e68c}}→- #f0e68c
TemplateData
This template generates a stylized color box that displays a color name or value in that color alongside a matching swatch, automatically selecting a light or dark background to ensure the color name remains legible for all colors.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Color | 1 color | CSS name or hex code of color
| String | suggested |