Template:Color/doc

< Template:Color
自由之民讨论 | 贡献2020年9月7日 (一) 18:26的版本 (创建页面,内容为“来自:https://meta.wikimedia.org/wiki/Template:Color {{t|Documentation subpage}} __NOTOC__ <!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE -…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

来自:https://meta.wikimedia.org/wiki/Template:Color {{Documentation subpage}}

This template can be used to specify the foreground color of a span of text. Acceptable values are RGB hex codes, e.g. #C9E72A, or any of the w:en:web colors: red, blue, green, moccasin, darkorchid, etc.

Usage

  • {{color|name of color or hex code of color|Text}}

For example:

  • {{color|red|Hello, world!}} → Hello, world!
  • {{color|#00F000|Hello, world!}} → Hello, world!

If the second parameter is omitted, the color value is displayed as text:

  • {{color|#00F000}} → #00F000
  • {{color|red}} → red

Performance considerations

The template generates an HTML span tag:

<span style="color:{{{1}}}">{{{2}}}</span>

It runs at speeds in excess of 700 per second, and so is functionally identical to using the HTML markup directly.

Template data

{{TemplateDataHeader}} <templatedata> {

       "description": "The color template can be used to add a span of text with any given text color",
       "params": {
               "1": {
                       "label": "Color",
                       "description": "CSS name of color or hex code of color, e.g. 'red' or '#00F000'.",
                       "type": "string",
                       "required": true
               },
               "2": {
                       "label": "Text",
                       "description": "The string of text to be formatted in the desired color",
                       "type": "string",
                       "required": true
               }
       }

} </templatedata>


See also

  • {{tl|font color}}, sets both text and background color