Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Table style

Template page
Template documentation

Usage

  • This template allows shorthand table styling parameters. It supports an unlimited number of shorthand codes, each of which will output one or more CSS style rules.
  • Raw CSS style rules that do not have a shortcut in the list below can be used instead of or in combination with the shorthand codes. Any parameter provided to the template that is not recognised as a defined shortcut code will be treated as a presumed raw CSS style rule and output essentially as is.
    • The template automatically adds a terminal semicolon (;) for all the CSS style rules it outputs. This means that technically you should not end the raw CSS rules you include with a semicolon, but since this only results in ;; which web browsers handle just fine, it really doesn't matter.

List of parameters

The shows all currently valid formatting codes, their associated aliases, and the actual CSS rules generated from them. For a full list of these supported codes, see Template:Table style on Wikisource.

Examples

{{ts|ar|ba|sc}} produces → style="text-align:right; border:1px solid black; font-variant:small-caps;"

{{table style|ar|vtb|pr2}} produces → style="text-align:right; vertical-align:text-bottom; padding-right:2em;"

Shorthand codes combined with CSS style rules

{{ts|text-align:right|pr2}} produces style="text-align:right; padding-right:2em;"

Where to place the template in a table?

Either at the start of the table, or on a row break, or for an individual cell.

In the following example the templates first sets the text in all the cells to be centered ({{ts|ac}}). Then on the second row (after the heading row) all the text in the row to be left justified ({{ts|al}}), finally the third row second column (the number of years) to be right justified ({{ts|ar}}).

 {|class="wikitable" {{ts|ac}}
 |-
 !Location
 !Number of years
 !Annual average rainfall in inches
 |-
 |Basra|||18||6-68
 |-{{ts|al}}
 |Bagdad||29||6-64
 |-
 |Mosul||{{ts|ar}}|4||16-71
 |}

Display as:

Location Number of years Annual average rainfall in inches
Basra 18 6-68
Bagdad 29 6-64
Mosul 4 16-71

Note

Not all table styling works everywhere, which is a limitation from HTML/CSS. As mentioned above, styles can be applied to a whole table, to an individual table row, or to individual table cells. Most styles work when applied to cells or whole tables. Far fewer styles work on table rows. If you see unexpected results even when the usage looks correct, this may be the problem.

The above documentation is transcluded from Template:Table style/doc.


Cookies help us deliver our services. By using our services, you agree to our use of cookies.