Permanently protected template

Template:Optional style

From Wikisource
Jump to navigation Jump to search
Template documentation[view] [edit] [history] [purge]


Utility template for constructing optional style attributes. This is probably only useful in other templates.

It allows to create a style with any number of rules, omitting any not given (or blank) and omitting the entire style attribute if none are given.

This means that this:



{{optional style
 | padding-top = {{{padding-top|}}}
 | padding-bottom = {{{padding-bottom|}}}


  • Any given parameters are used as the CSS property name (e.g. padding-top). The parameter value is the property value (e.g. blank or 2em).
  • style: Pre-built CSS (i.e. like padding-left:2em; padding-right:1em; (the semicolons between items are important). Will be added at the end of the style, so it will override any other parameter (in this case, padding-left would be overridden by style.

Examples =


* {{optional style
 | padding-top = 2em
 | padding-bottom =
  • style="padding-top:2em;"

Example: All parameters blank

* {{optional style
 | padding-top =
 | padding-bottom =

Example: With a style parameter

* {{optional style
 | padding-top = 4em;
 | padding-bottom =
 | style = padding-left:2em;padding-top:1em;
  • style="padding-top:4em;padding-left:2em;padding-top:1em;"