Template:Font
{{#ifeq:font |doc
|
{{#ifeq:show |show
|| icon | This is a documentation subpage for Template:Terminate sentence It may contain usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. |
}}{{#if:|
|{{#ifexist:Template:Font
| [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
|
}}
}}
|
}}
| Warning | This template is used on approximately 12,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
{{font}} is used to define text styles, for example, size and color. It can also be used to inject CSS. This can be useful when needed to change "I" in Arial to "{{ safesubst:#if: I |I|{{{text}}}}}" in Times New Roman, since in Arial, uppercase "I" looks the same as lowercase "L".
Use
{{font|TEXT(or「text=TEXT」)|font=FONT|size=SIZE(px/em/pt/%)|color=COLOR|bgcolor=BACKGROUND COLOR|css=CSS}}
Note that for accessibility reasons MOS:FONTSIZE says: "No text should be reduced below 85% of the page's default font size." Also, font sizes should be set as percentages, not fixed font sizes, because: "This improves accessibility for visually impaired users who use a large default font size."
If a table has been set overall to style="font-size:90%;", then setting an individual cell to {{font|size=85%|...}} actually is 0.85 of 0.9 which is 76.5%.
Parameter list
text- The text to be changed.
font- The text's font.
A list of fonts supported by Wikipedia can be found here: Wikipedia:Typography#Available fonts. size- The size of the text. Possible unit include
px,em,pt,%. color- The color of the text.
bgcolor- The background color.
css- A CSS style.
Examples
| Markup | Display |
|---|---|
{{font|text=Some text.|font=|size=|color=}} |
{{{1}}}|Some text.}} |
{{font|text=Some text.|font=Comic Sans MS|size=20px|color=green}} |
{{{1}}}|Some text.}} |
{{font|Illinois|font=Times New Roman|size=20px}} |
Illinois|{{{text}}}}} |
{{font|Illinois|font=Arial|size=20px}} |
Illinois|{{{text}}}}} |
{{font|Коричневый текст.|font=Times New Roman Cyr|size=20px|color=#7f5620}}
|
Коричневый текст.|{{{text}}}}} |
{{font|text=Hello World!|font=Century Gothic|size=35px|color=#bf00bf}}
|
{{{1}}}|Hello World!}} |
{{font|text=囧囧囧囧囧|font=Simhei|color=#c9b295|bgcolor=#364d6a}}
|
{{{1}}}|囧囧囧囧囧}} |
{{font|text=You can use all available parameters, |font=Georgia|size=20px|color=#5a7aad|bgcolor=#f9f9ef}}
|
{{{1}}}|You can use all available parameters,}} |
{{font|text=or just a single one.|size=25px}}
|
{{{1}}}|or just a single one.}} |
Limitations
This template should not be used around multiple paragraphs. For example, it should not be used around multiple bullet or numbered points or more than one cell of a table. It may, however, surround as many uses of <br /> as desired.
Template data
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Font|Template:Font|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Font|Template:Font|Template:Font}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}.
|#default=[1]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}} }}|This is the {{#if:|TemplateData|TemplateData}} for this template used by TemplateWizard, VisualEditor and other tools. {{#switch:
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Font|Template:Font|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AFont%7CFont%7CFont%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Font|Template:Font|Template:Font}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}}.
|#default=[2]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Font|its|this}} TemplateData}} }}}}
TemplateData for Font
{{#if:
| {{{demospace}}}
| {{#ifeq:Template|Template
| template
| other
}}
}}
| template = {{safesubst:#if:{{safesubst:#ifeq:Font|sandbox|1}}{{safesubst:#ifeq:Font|doc|1}}||
}} | other | #default = }} {{ safesubst:#if: |{{ safesubst:#ifeq:{{{demo}}} |no
| |
}} |{{ safesubst:#ifeq:Template|Template
| |
}}}}
class="{{safesubst:#switch:
{{safesubst:#if:
|
{{{demospace}}} | main | other
}} }} |
main = cot-header-mainspace | other | #default = cot-header-other
}}" style="{{safesubst:#if:#ddd|background:#ddd|{{ safesubst:#if: |
no | {{safesubst:#switch:
{{safesubst:#if:
|
{{{demospace}}} | main | other
}} }} |
main = background:#F0F2F5 | other | #default = background:#CCFFCC
}} }} |
Template | {{safesubst:#switch:
{{safesubst:#if:
|
{{{demospace}}} | main | other
}} }} |
main = background:#F0F2F5 | other | #default = background:#CCFFCC
}} }}}}}}; font-size:87%; padding:0.2em 0.3em; text-align:{{safesubst:#if:|left|{{safesubst:#if:|left|center}}}}; {{safesubst:#if:|color: {{{fc}}};|{{safesubst:#if:#ddd|color:#202122|{{ safesubst:#if: |
no | color:black;
}} |
Template | color:black;
}}}}}}}}" | Template data parameterlist
{{safesubst:#if: |
- | The following is a closed discussion. {{safesubst:#switch:
{{safesubst:#if:
|
{{{demospace}}} | main | other
}} }} |
main = Template:FormattingError | other | #default = Please do not modify it.
}} }} | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
<templatedata> { "description": "Set text font, size, and color.", "params": { "text": {}, "1": {}, "font": {}, "size": {}, "color": {}, "bgcolor": {}, "title": {}, "css": {} } } </templatedata> |
See also
- {{font color}}
- {{script}}
| Code for inline content | Code for block content | Size | Result | ||
|---|---|---|---|---|---|
{{small|text}} |
{{smalldiv|text}} |
85% | text{{SAFESUBST:#if:text | }} | |
{{resize|text}} |
{{resizediv|text}} |
90% | {{safesubst:#if: | yes|div|span}} style="font-size:text;"></{{safesubst:#ifeq:|yes|div|span}}> | yes|div|span}} style="font-size:90%;">text</{{safesubst:#ifeq:|yes|div|span}}>
}} |
| none | none | 100% | text | ||
{{large|text}} |
{{largediv|text}} |
120% | text | ||
{{huge|text}} |
180% | {{safesubst:#switch: sub | normal = text | #default=text
}} | |
{{resize|x%|text}} |
{{resizediv|x%|text}} |
custom | varies | ||
{{font|size=x%}} |
custom | varies |
{{safesubst:#if:{{safesubst:#ifeq:Font|sandbox|1}}{{safesubst:#ifeq:Font|doc|1}}||
}}