Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Co: Difference between revisions

Template page
categorization
Proton One (talk | contribs)
Adding design variable colors
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{{{{|safesubst:}}}#if:{{{3|}}}|<span style="background-color:{{{2|inherit}}};color:{{{1|inherit}}};">{{{3|}}}</span>|<span style="color:{{{1|inherit}}};">{{{2|}}}</span>}}<noinclude>
<includeonly>{{{{{|safesubst:}}}#if:{{{3|}}}|<span style="background-color:{{{2|inherit}}};color:{{design var|{{{1|inherit}}}}};">{{{3|}}}</span>|<span style="color:{{design var|{{{1|inherit}}}}};">{{{2|}}}</span>}}</includeonly><noinclude>
 
{{documentation}}
==Template Code==
<nowiki>{{{{{|safesubst:}}}#if:{{{3|}}}|<span style="background-color:{{{2|inherit}}};color:{{{1|inherit}}};">{{{3|}}}</span>|<span style="color:{{{1|inherit}}};">{{{2|}}}</span>}}</nowiki>
 
Have fun if you can make sense of it.
 
==Usage==
<nowiki>{{co|<text color>|<background color>|<text>}}</nowiki>
 
==Example==
<nowiki>{{co|red||This text isn't yellow.}}</nowiki> {{co|red||This text isn't yellow.}}<br>
<nowiki>{{co||green|This text has a green background.}}</nowiki> {{co||green|This text has a green background.}}<br>
<nowiki>{{co|#0033CC||This text uses an HTML color code.}}</nowiki> {{co|#0033CC||This text uses an HTML color code.}}
 
Note the double brackets || which means that that section is empty. Do not miss brackets, all three are needed.
</noinclude>
 
<noinclude>
[[Category:Template]]
</noinclude>
</noinclude>

Latest revision as of 03:32, 3 December 2025

Template documentation (for the above template, sometimes hidden or invisible)
Description
This template is used to color some text.
Syntax
{{Co|<text color>|<background color>|<text>}}
{{Co|<text color>|<text>}}
Parameters
text color
Sets the text color. Default value is "inherit"[1]. Text color is passed through {{design var}} to automatically interpret and replace select color names with design variables. Colors can be given either by color name[2] (e.g. red or green) or values[3] (like #FF0000).
background color
Sets the background color. Default value is "inherit". For valid values see text color.
text
The text to be colored.
Sample
{{co|red|This text isn't yellow.}}
gives ...
This text isn't yellow.
{{co||green|This text has a green background.}}
gives ...
This text has a green background.

Note: Note the double pipe char || which means that that section is empty. The background color parameter may be safely omitted without the use of double pipes, but double pipes must be used if only a background color is desired.

{{co|black|lightyellow|Text and background color.}}
gives ...
Text and background color.
{{co|#0033CC|This text uses an hex color code.}}
gives ...
This text uses an hex color code.
References
  1. ^ inherit - The color used by the HTML parent element.
  2. ^ https://www.w3schools.com/colors/colors_names.asp [2022-05-29]
  3. ^ https://www.w3schools.com/colors/colors_hex.asp [2022-05-29]
Visit Template:Co/doc to edit this text! (How does this work?) (Refresh this text - why?)