Template:CssPre

Introduction[edit]

This template is for generating a PRE element or other HTML element with pre-defined styles to help with readability.

Custom parameters are also available.


Usage[edit]

Syntax[edit]

{{CssPre|<width>|<font-size>|<pad-size>|tag=<element>|b=<value>|t=<value>|custom=<style>|content=<value>}}

{{CssPre|<width>|<font-size>|<pad-size>|tag=<element>|b=<value>|t=<value>
  | custom = <style>
  | content = <value>
}}

Parameters[edit]

All parameters are optional.

  • Named Parameters
    • tag: The name of the HTML element to be rendered.
      Default value is pre.
    • b: Set to n to indicate that the element is not a block-level element, such as tag=code.
      By doing so, the display, white-space and word-wrap styles will be suppressed.
    • t: Set to y to indicate that the content is a template.
      By doing so, leading and trailing braces will be output.
    • custom: Any custom CSS you want to be included in the style attribute.
      Each style must be properly formatted: <name>:<value>;
    • content: Anything that should appear within the element.
      When providing Wikitext that should not be interpreted, surrounded the content with <nowiki></nowiki> tags. (see example)
  • Unnamed Parameters
  1. width: The value for the width. Default value is 80%
    The value is used exactly as it is provided.
    To prevent this parameter from being used, set it to 0.
    This should be done for inline elements such as tag=code.
  2. font-size: The value for the font-size (measured in em). Default value is 1.2
  3. pad-size: The value for the padding (measured in em). Default value is 1

Examples[edit]

No Style[edit]

  • Standard PRE block without a style attribute.
<pre>
{{MyTemplate
  | parm1 = 
  | parm2 = 
}}
</pre>

Output:

{{MyTemplate
  | parm1 = 
  | parm2 = 
}}

With CssPre[edit]

  • Basic example with only the t and content parameters provided.
{{CssPre|t=y
| content = <nowiki>MyTemplate
  | parm1 = 
  | parm2 = </nowiki>
}}

Output:

{{MyTemplate
  | parm1 = 
  | parm2 = 
}}

Custom CSS[edit]

  • Changes the font color to blue using custom.
{{CssPre|t=y|custom=color:blue;
| content = <nowiki>MyTemplate
  | parm1 = 
  | parm2 = </nowiki>
}}

Output:

{{MyTemplate
  | parm1 = 
  | parm2 = 
}}

Sizes[edit]

  • Custom size overrides
  1. Width = 50%
  2. Font = 1.5
  3. Padding = 2
{{CssPre|50%|1.5|2|t=y
| content = <nowiki>MyTemplate
  | parm1 = 
  | parm2 = </nowiki>
}}

Output:

{{MyTemplate
  | parm1 = 
  | parm2 = 
}}

Inline Element[edit]

  • A CODE element.
{{CssPre|tag=code|b=n|t=y|0||0.1
  | content = <nowiki>SimpleTemplate|parm1|parm2</nowiki>
}}

Output:

{{SimpleTemplate|parm1|parm2}}


Default Output[edit]

<pre style="display:inline-block;width:80%;white-space:pre-wrap;word-wrap:break-word;font-size:1.2em;padding:1em;"></pre>

This article uses material from the "Template:CssPre" article on FFXIclopedia and is licensed under the CC-BY-SA License.