Difference between revisions of "Template:Font color/doc"

From blackwiki
Jump to navigation Jump to search
imported>Cpiral
(+L color generation guide, MoS info)
imported>Cpiral
(→‎Examples: + several link examples, coinciding with rewritten explanation of links and bg colors)
Line 122: Line 122:
 
||<code>{<nowiki/>{font color'''{{big|{{!}}}}'''bg=yellow|text=default text in yellow background}}</code>
 
||<code>{<nowiki/>{font color'''{{big|{{!}}}}'''bg=yellow|text=default text in yellow background}}</code>
 
|{{font color|bg=yellow|text=default text in yellow background}}
 
|{{font color|bg=yellow|text=default text in yellow background}}
 
 
|}
 
|}
 
The {{para|link}} parameter is useful where a link is placed in a colored header such as a navbox. For example, if the header was blue, you would leave the background color blank and set the font color to white. {{para|link|yes}} sets the link to the text, otherwise it is set to the value of {{para|link}}.
 
  
 
{|class=wikitable
 
{|class=wikitable
Line 139: Line 136:
 
|<code><nowiki>{{font color|text=Example|link=Wikipedia:Sandbox|bg=blue|fg=white}}</nowiki></code>
 
|<code><nowiki>{{font color|text=Example|link=Wikipedia:Sandbox|bg=blue|fg=white}}</nowiki></code>
 
|{{font color|text=Example|link=Wikipedia:Sandbox|bg=blue|fg=white}}
 
|{{font color|text=Example|link=Wikipedia:Sandbox|bg=blue|fg=white}}
|}<!--
+
|}
 +
 
 +
The {{para|link}} parameter is a good way to colorize wikilinks,
 +
and it is about as much typing as the [[wp:pipe trick|pipe trick]].
 +
*<code>[<nowiki />[Wikipedia:Sandbox|{<nowiki />{font color|white|blue|Example}}]]</code> &rarr; [[Wikipedia:Sandbox|{{font color|white|blue|Example}}]]  Linked by the pipe trick. {{OK}}
 +
*{{#invoke:DemoTemplate|font color|white|blue|Example|link=Wikipedia:Sandbox}}  Linked by {{tl|font color}} {{OK}}
 +
*{{#invoke:DemoTemplate|font color|red|[[Wikipedia:Sandbox]]}} Not "red" like it said, because text is a wikilink. {{cross}}
 +
*{{#invoke:DemoTemplate|font color|white|green|[[Wikipedia:Sandborax]]}}  Not white on green: text is a wikilink. {{cross}}
 +
 
 +
<span style=background-color:yellow>
 +
This span is style=background-color:yellow.
 +
So when we then
 +
{{#invoke:DemoTemplate|font color|red|some red text}}.<br />
 +
And we can linked with purple color to ''{{font color|purple|The Color Purple|link=yes}}.''
 +
{{spaces|5}}OK span ending.</span>
 +
<!--
  
 
--><includeonly>For more examples see [[/testcases]].</includeonly>
 
--><includeonly>For more examples see [[/testcases]].</includeonly>

Revision as of 09:50, 2 December 2015

Purpose

This is how you insert colorized text, such as red, orange, yellow, green, blue and indigo, violet, and many others.

It's needed for matching a color theme such as in sports templates. You can specify a background color too.

You can make any text link to any page. (See "yellow" and "blue" above.)

For example, giving your plain [[wikilink]], you get

header 1 header 2 header 3
row 1, cell 1 wikilink row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

You need {{font color | green | wikilink | link = yes }}

header 1 header 2 header 3
row 1, cell 1 wikilink row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

Font color will use the latest Wikipedia:HTML5 recommendations, inserting the span tag attributes

style=background-color:
style=color:

for you, so your page increases its readability and usability in the wikitext and its rendering.

Usage

{{Font color}} has a one-color and a two-color form:

{{font color|color|text}}
{{font color|text color|background color|text}}.

Either form has a |link= option, for colorizing (otherwise blue or red) wikilink text.

|link=yes[[text]]
|link=fullpagename[[fullpagename]]

You can also name the other fields.

{{font color|fg=color|text=text}}
{{font color|fg=text color|bg=background color|text=text}}

You can name |fg= or |bg=, which is nice, but... if you name either of them, you must also name |text=, which is a compromise. (See Help:Template#Parameters for why.)

Parameters

Script error: No such module "aligned table".

Or

Script error: No such module "aligned table".

Examples

Markup Renders as
{{font color|green|green text}} green text
{{font color|blue|do not style text as a link}} do not style text as a link
{{font color|white|black|white with black background}} white with black background
{{font color||yellow|default text in yellow background}} default text in yellow background
{{font color|bg=yellow|text=default text in yellow background}} default text in yellow background
Markup Renders as
{{font color|white|blue|Wikipedia:Example|link=yes}} Wikipedia:Example
{{font color|white|blue|Example|link=Wikipedia:Sandbox}} Example
{{font color|text=Example|link=Wikipedia:Sandbox|bg=blue|fg=white}} Example

The |link= parameter is a good way to colorize wikilinks, and it is about as much typing as the pipe trick.

  • [[Wikipedia:Sandbox|{{font color|white|blue|Example}}]]Example Linked by the pipe trick. Template:OK
  • {{font color|white|blue|Example|link=Wikipedia:Sandbox}}Example Linked by {{font color}} Template:OK
  • {{font color|red|[[Wikipedia:Sandbox]]}}Wikipedia:Sandbox Not "red" like it said, because text is a wikilink.
  1. REDIRECT Template:Xmark
  • {{font color|white|green|[[Wikipedia:Sandborax]]}}Wikipedia:Sandborax Not white on green: text is a wikilink.
  1. REDIRECT Template:Xmark

This span is style=background-color:yellow. So when we then {{font color|red|some red text}}some red text.
And we can linked with purple color to The Color Purple.      OK span ending.

For actual mainspace template usage, here are search links for

See also