模板:Table cell templates/doc

来自决策链云智库

The templates in this series are designed to be used in a table to make a cell with text in that cell, with an appropriately colored background. They are commonly used in comparison tables. Most of these templates should not be used simply to produce a background color, use them according to their meaning.

For example, {{yes}} makes a cell with a green background. The text in the cell is taken from the first parameter; {{yes|Sure}} would output "Sure" otherwise it defaults to "Yes". Most templates allow authors to override the default text in this way, some require text put after the template call and some also need a vertical bar in between: {{''table cell template''}} ''text'' or {{''table cell template''}} | ''text''. This information, the colors and default texts are found in the table below.

red-outlined triangle containing exclamation point Important: If you want to use other attributes for the table cells, e.g. colspan, rowspan, or style, they need to be put before the template call, and there must be no vertical bar (aka pipe) | in-between them:

Yes No
colspan=2 style="border:solid 3px Maroon" 模板:Yes-No
...
!{{Yes}} ||{{No}} ||rowspan=2 {{n/a}}
|-
|colspan=2 style="border:solid 3px Maroon" {{Yes-No}}
...

Templates

Table cell templates
Class[1] Default Customized
Syntax Preview Syntax Preview
table-rh {{rh}} | Row header[2] 模板:Rh | Row header {{rh|<align=right>}} | Row header 模板:Rh | Row header
{{rh2}} | Row header[2] 模板:Rh2 | Row header {{rh2|<align=center>}} | Row header 模板:Rh2 | Row header
table-yes {{yes}} Yes {{yes|<customized [[Plain text|text]]>}} customized text
{{yes C}} 模板:Yes C {{yes C|<customized [[Plain text|text]]>}} 模板:Yes C
{{yes O}} 模板:Yes O {{yes O|<customized [[Plain text|text]]>}} 模板:Yes O
{{yes N}} 模板:Yes N {{yes N|<customized [[Plain text|text]]>}} 模板:Yes N
table-maybe {{maybe}} 模板:Maybe {{maybe|<customized [[Plain text|text]]>}} 模板:Maybe
table-no {{no}} No {{no|<customized [[Plain text|text]]>}} customized text
{{no O}} 模板:No O {{no O|<customized [[Plain text|text]]>}} 模板:No O
{{no X}} 模板:No X {{no X|<customized [[Plain text|text]]>}} 模板:No X
{{eliminated}} 模板:Eliminated {{eliminated|<dropped out>}} 模板:Eliminated
{{lost}} 模板:Lost {{lost|<missing>}} 模板:Lost
{{active fire|<12%>}}[3] 模板:Active fire
{{safe}} 模板:Safe {{safe|<protected>}} 模板:Safe
{{no Y}} 模板:No Y {{no Y|<customized [[plain text|text]]>}} 模板:No Y
table-active {{active}} 模板:Active {{active|<live>}} 模板:Active
table-siteactive {{site active}} 模板:Site active {{site active|<up>}} 模板:Site active
{{coming soon}} 模板:Coming soon {{coming soon|<second half of the year>}} 模板:Coming soon
table-siteinactive {{site inactive}} 模板:Site inactive {{site inactive|<down>}} 模板:Site inactive
table-success {{success}} 模板:Success {{success|<mission complete>}} 模板:Success
{{operational}} 模板:Operational {{operational|<returning data>}} 模板:Operational
table-failure {{failure}} 模板:Failure {{failure|<wrong orbit>}} 模板:Failure
table-yes2 {{yes2}} 模板:Yes2 {{yes2|<text>}} 模板:Yes2
{{good}} 模板:Good {{good|<A>}} 模板:Good
{{ya}} 模板:Ya {{ya|<text=ya>}} 模板:Ya
{{ya|<Ya>}} 模板:Ya {{ya|<text>|<link=WP:ALT>}} 模板:Ya
{{yan}} 模板:Yan {{yan|<text=ya>}} 模板:Yan
{{won}} 模板:Won {{won|<text=white>|<color=darkblue>|<winner>}} 模板:Won
{{won|<place=1>}} 模板:Won {{won|<place=gold>}} 模板:Won
{{won|<place=2>}} 模板:Won {{won|<place=silver>}} 模板:Won
{{won|<place=3>}} 模板:Won {{won|<place=bronze>}} 模板:Won
{{WinDL}} 模板:WinDL {{WinDL|<win>}} 模板:WinDL
{{WinDL|<res=D>}} 模板:WinDL {{WinDL|<res=draw>}} 模板:WinDL
{{WinDL|<res=L>}} 模板:WinDL {{WinDL|<res=loss>}} 模板:WinDL
table-no2 {{no2}} 模板:No2 {{no2|<text>}} 模板:No2
{{na}} 模板:Na {{na|<text=na>}} 模板:Na
{{na|<Na>}} 模板:Na {{na|<text>|<link=WP:ALT>}} 模板:Na
{{nan}} 模板:Nan {{nan|<text=na>}} 模板:Nan
{{nom}} 模板:Nom {{nom|<5>}} 模板:Nom
{{notnom}} 模板:Notnom {{notnom|<not selected>}} 模板:Notnom
{{sho}} 模板:Sho {{sho|<proposed>}} 模板:Sho
{{longlisted}} 模板:Longlisted {{longlisted|<rejected>}} 模板:Longlisted
{{TBA}} 模板:TBA {{TBA|<to be announced>}} 模板:TBA
table-partial {{partial}} 模板:Partial {{partial|<almost done>}} 模板:Partial
{{Regional}} 模板:Regional {{Regional|<Uyghur>}} 模板:Regional
{{MaybeCheck}} 模板:MaybeCheck {{MaybeCheck|<text=possibly>}} 模板:MaybeCheck
{{MaybeCheck|<possibly>}} 模板:MaybeCheck {{MaybeCheck|<text>|<link=WP:ALT>}} 模板:MaybeCheck
{{partial success}} 模板:Partial success {{partial success|<
reached orbit and returned pictures>
}}
模板:Partial success
{{partial failure}} 模板:Partial failure {{partial failure|<[[Cubesat]] not deployed>}} 模板:Partial failure
{{okay}} 模板:Okay {{okay|<C>}} 模板:Okay
{{Yes-No}} 模板:Yes-No {{Yes-No|<yes with an if; no with a but>}} 模板:Yes-No
{{some}} 模板:Some {{some|<many>}} 模板:Some
{{pending}} 模板:Pending {{pending|<awaiting>}} 模板:Pending
{{sometimes}} 模板:Sometimes {{sometimes|<occasionally>}} 模板:Sometimes
{{rarely}} 模板:Rarely {{rarely|<seldom>}} 模板:Rarely
{{usually}} 模板:Usually {{usually|<commonly>}} 模板:Usually
{{unofficial}} 模板:Unofficial {{unofficial|<''de facto''>}} 模板:Unofficial
{{unofficial2}} 模板:Unofficial2 {{unofficial2|<''de facto''>}} 模板:Unofficial2
{{nonpartisan}} 模板:Nonpartisan {{nonpartisan|<impartial>}} 模板:Nonpartisan
table-any {{any}} 模板:Any {{any|<anyone>}} 模板:Any
table-automatic {{perhaps}} 模板:Perhaps {{perhaps|<maybe>}} 模板:Perhaps
table-draw {{draw}} 模板:Draw {{draw|<1:1>}} 模板:Draw
table-noAttempt {{No attempt}} 模板:No attempt {{No attempt|<No landing attempted>}} 模板:No attempt
table-na {{n/a}} {{n/a|<unavailable>}} unavailable
{{varies}} 模板:Varies {{varies|<differs>}} 模板:Varies
{{non-album single}}[4] 模板:Non-album single {{non-album single|<EP>}} 模板:Non-album single
{{unreleased}} 模板:Unreleased {{unreleased|<shelved>}} 模板:Unreleased
{{BLACK}} 模板:BLACK {{BLACK|<banned>}} 模板:BLACK
{{sdash}} 模板:Sdash {{sdash|<[[File:Dash.svg>|<13px>|<dash icon]]>}} 模板:Sdash
{{vacant}} 模板:Vacant {{vacant|<missing>}} 模板:Vacant
table-unknown {{unknown}} 模板:Unknown {{unknown|<?>}} 模板:Unknown
{{dunno}} 模板:Dunno {{dunno|<not sure>}} 模板:Dunno
table-included {{included}} 模板:Included {{included|<incorporated>}} 模板:Included
noresult {{no result}} 模板:No result {{no result|<NR>}} 模板:No result
table-planned {{planned}} 模板:Planned {{planned|<July 2028>}} 模板:Planned
table-scheduled {{scheduled}} 模板:Scheduled {{scheduled|<3 March 2027>}} 模板:Scheduled
table-software[5] {{beta}} 模板:Beta {{beta|<preview>}} 模板:Beta
{{table-experimental}} 模板:Table-experimental {{table-experimental|<lab>}} 模板:Table-experimental
{{nightly}} 模板:Nightly {{nightly|<dev>}} 模板:Nightly
{{release-candidate}} 模板:Release-candidate {{release-candidate|<RC>}} 模板:Release-candidate
{{open source}} 模板:Open source {{open source|<software libre>}} 模板:Open source
{{free}} 模板:Free {{free|<empty>}} 模板:Free
{{proprietary}} 模板:Proprietary {{proprietary|<custom extension>}} 模板:Proprietary
{{nonfree}} 模板:Nonfree {{nonfree|<paid>}} 模板:Nonfree
{{needs}} 模板:Needs {{needs|<req.>}} 模板:Needs
table-depends {{depends}} 模板:Depends {{depends|<vendor-defined>}} 模板:Depends
table-dropped {{dropped}} 模板:Dropped {{dropped|<discontinued>}} 模板:Dropped
{{terminated}} 模板:Terminated {{terminated|<fired>}} 模板:Terminated
incorrect {{incorrect}} 模板:Incorrect {{incorrect|<wrong>}} 模板:Incorrect
table-debate {{D-P}} 模板:D-P {{D-P|<present>}} 模板:D-P
{{D-A}} 模板:D-A {{D-A|<absent>}} 模板:D-A
{{D-I}} 模板:D-I {{D-I|<invited>}} 模板:D-I
{{D-O}} 模板:D-O {{D-O|<invited to other debate>}} 模板:D-O
{{D-N}} 模板:D-N {{D-N|<not invited>}} 模板:D-N
{{D-Nv}} 模板:D-Nv {{D-Nv|<not voting>}} 模板:D-Nv
{{D-W}} 模板:D-W {{D-W|<withdrawn>}} 模板:D-W
{{D-Out}} 模板:D-Out {{D-Out|<out of race>}} 模板:D-Out
table-cast[6] {{CMain}} 模板:CMain {{CMain|<text>}} 模板:CMain
{{CAlso starring}} 模板:CAlso starring {{CAlso starring|<costar>}} 模板:CAlso starring
{{CRecurring}} 模板:CRecurring {{CRecurring|<regular guest>}} 模板:CRecurring
{{CGuest}} 模板:CGuest {{CGuest|<victim>}} 模板:CGuest
{{COther}} 模板:COther {{COther|<ensemble>}} 模板:COther
{{CNone}} Does not appear {{CNone|<cast>}} cast
{{CEmpty}} 模板:CEmpty
{{CRemoved}} 模板:CRemoved {{CRemoved|<edited>}} 模板:CRemoved
{{CFinalist}} 模板:CFinalist {{CFinalist|<contender>}} 模板:CFinalist
{{CFinalist|<place=3rd Place>}} 模板:CFinalist {{CFinalist|<place=third place>}} 模板:CFinalist
{{exempt}} 模板:Exempt {{Black Exempt}} 模板:Black Exempt
{{nocontest}} 模板:Nocontest {{nocontest|<rescheduled>}} 模板:Nocontest
{{Runner-up}} 模板:Runner-up {{Runner-up|<2nd Place>}} 模板:Runner-up
{{Quit}} 模板:Quit {{Quit|<left>}} 模板:Quit
no class {{not yet}} 模板:Not yet {{not yet|<NY>}} 模板:Not yet
{{optional}} 模板:Optional {{optional|<non-mandatory>}} 模板:Optional
{{shade|<100>}}% 模板:Shade% {{shade|<color=blue>|<100>}}% 模板:Shade%
{{shade|<75>}}% 模板:Shade% {{shade|<color=blue>|<75>|<73–78>}}% 模板:Shade%
{{shade|<25>}}% 模板:Shade% {{shade|<color=blue>|<25>|<{{val|25|2|u=%}}>}} 模板:Shade
{{shade|<0>}}% 模板:Shade% {{shade|<color=blue>|<0>}}% 模板:Shade%
{{Cell color|<90>|<25>|<90>}} 模板:Cell color {{Cell color|<90>|<25>|<90>|<a80202>|<0d89fc>}} 模板:Cell color
{{Cell color|<58>|<25>|<90>}} 模板:Cell color {{Cell color|<58>|<25>|<90>|<a80202>|<0d89fc>}} 模板:Cell color
{{Cell color|<25>|<25>|<90>}} 模板:Cell color {{Cell color|<25>|<25>|<90>|<a80202>|<0d89fc>}} 模板:Cell color
{{CellCategory|<2>|<Some text>}} 模板:CellCategory

Code

Common code to most if not all the templates in this series:

style="background: #abcdef; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|text-transform: capitalize;}}}" class="automatic table-automatic"| {{{1|text}}}


Creating new templates

To make a new table cell template you can use:

{{subst:Table cell templates|text= default text |bg= background color |class= a class name without prefix |align= standard horizontal alignment}}

You should leave out the align parameter and often the class parameter is unnecessary, too.

Add the new template to the table in the common documentation afterwards. Please consider reusing one of the other templates and please choose the color sensibly.

If you find a table cell template that does not take a parameter and you want to be able to change the text in the cell, do not duplicate the template! Instead, edit the template and change the text to a default parameter substitution. For example, if a template's text is Dropped, change that to {{{1|Dropped}}}.

style="background: #abcdef; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|}}}" class="automatic table-automatic"| {{{1|text}}}

Choosing a color

When changing or creating a new template, follow the use of colour guidelines and the color accessibility guidelines when choosing the background color and, sometimes, the text color. Many of these templates can be used with links to other articles or references, so the links should be clearly identifiable against the background color. You can check contrast level using the WebAIM contrast checker by setting the foreground color to the blue link color. Contrast should be at the minimum WCAG AA level and, whenever possible, at WCAG AAA level. Wikipedia:Manual of Style/Accessibility/Colors has a set of colors that comply with WCAG AAA and WCAG AA for unvisited links and normal text.

Color subpage

All templates should either have a /bgcolor subpage that contains nothing but a valid CSS color code, possibly wrapped in nowiki tags, e.g. #BFD, which can be included with background: {{/bgcolor}}; in the style attribute, or they should reference another template's subpage, e.g. background: {{Template:Yes2/bgcolor}};. Alternatively, the /bgcolor subpage may redirect to another color code subpage: #REDIRECT [[yes2/bgcolor]].

This way, pages that are using these templates may also use {{legend}} and similar templates which can reference the actual color: {{legend|{{yes2/bgcolor}}|supported}}

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Table cell templates in articles based on its TemplateData.

TemplateData for Table cell templates

One of several templates for styling individual table cells with standard contents and colors.

模板参数

此模板首选参数不换行的行内格式。

参数描述类型状态
text1

text to be displayed instead of the default; if this doesn't work put the text after the template, possibly with a vertical bar | in between

默认值
(template dependent)
内容可选
horizontal alignalign

text alignment inside the cell, either 'left', 'right', 'center' or 'justified'

推荐值
leftcenterrightjustified
默认值
center
字符串可选
stylestyle

a semicolon-separated list of additional CSS rules to be applied to the table cell

默认值
(template dependent)
字符串可选
background colorcolor

a valid CSS color value or name to override the standard cell background, only available with some templates

默认值
(template dependent)
单行文本可选

See also

Notes

  1. The HTML class of table cell templates may be referenced in a user stylesheet to change appearance.
  2. 2.0 2.1 Does not take a parameter; the content should be placed after the template call, separated by a pipe (|) character.
  3. This template is related to 模板:WikiProject link.
  4. This template is related to 模板:WikiProject link.
  5. This group of templates is related to 模板:WikiProject link.
  6. This group of templates is related to 模板:WikiProject link.