Template:Code

From MozillaWiki
Jump to: navigation, search

{{{1}}}

Documentation icon Template documentation[view] [edit] [history] [purge]

Usage

{{code}} is a front-end for the HTML element <code>, which is used to denote text that should be read as computer code (or as instructional text for data input).

Parameters

There are 5 parameters, of which 1 is unnamed and required, and the other 4 are named and optional.

Syntax

The template's syntax is

  • {{code|custom text |class= |id= |style= |lang= }}

Required parameter

1

Custom text

The text you wish to enclose in <code> tags.

Usage
  • {{code|1}}

Optional parameters

class

Custom class

Attribute a class to the text string.

Usage
  • {{code|1|class=}}

id

Custom id

Give the text string a custom id.

Usage
  • {{code|1|id=}}

style

Custom text styling

You can override the default output styling by using this parameter to specify CSS properties with appropriate values.

Note
  • When entering the CSS properties and values, use the normal format, separating the property from its value with a colon (:), and ending each property:value pair with a semicolon (;), e.g. css-property-1:value; css-property-2:value; css-property-3:value;. But, don't enclose the entry in double quotation marks ("…"). That is done automatically.
Usage
  • {{code|1|style=prop1:valueA; prop2:valueB;}}

lang

Custom programming language

Define the input coding languge.

Usage
  • {{code|1|lang=}}

Examples

Case What you type What you see
Basic use This is the code text}} This is the code text
class, id,
and lang
class=string|id=meta1|lang=text|Text string with meta-informtion}} Text string with meta-informtion
style style=color:green;background-color:#fff0d0;|This is the styled text}} This is the styled text
Wiki-formatting You ''can'' '''use''' {{sup|wiki}} <big>markup</big>}} You can use wiki markup

See also

  • {{abbr}}: inserts <abbr> tags to include a tooltip explanation of an abbreviation.
  • {{bdi}}: inserts <bdi> tags to allow for inline changes in text direction.
  • {{bdo}}: inserts <bdo> tags, forcing inline changes in text direction.
  • {{mark}}: inserts <mark> tags, highlighting the enclosed text.
  • {{samp}}: inserts <samp> tags.
  • {{var}}: inserts <var> tags.
  • {{varserif}}: inserts <var> tags with serif font styling.