Permanently protected template

Template:Table style

From Wikisource
Jump to navigation Jump to search

style=""

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

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.
  • Shorthand codes are managed in Module:table style/data.

List of parameters

The following list is automatically generated from the data in Module:Table style/data. It shows all currently valid formatting codes, their associated aliases, and the actual CSS rules generated from them.

CodeAliasesOutput CSS Style
ac
  • center
  • centre
  • align center
  • center align
  • align centre
  • centre align
text-align:center;
aj
  • justify
  • align justify
  • justify align
text-align:justify;
al
  • left
  • align left
  • left align
text-align:left;
ar
  • right
  • align right
  • right align
text-align:right;
asc
  • all small caps
  • all small capitals
font-variant:all-small-caps;
ba
  • border all
  • border
border:1px solid black;
ba.border:1px dotted black;
ba2border:2px solid black;
ba3border:3px solid black;
badborder:4px double black;
bb
  • border bottom
  • bottom border
border-bottom:1px solid black;
bb.border-bottom:1px dotted black;
bb2border-bottom:2px solid black;
bb2.border-bottom:2px dotted black;
bb3border-bottom:3px solid black;
bb4xd
  • bbd
border-bottom:4px double black;
bbtborder-bottom:0px solid transparent;
bbt1border-bottom:1px solid transparent;
bc
  • border collapse
  • collapse
border-collapse:collapse;
bgt
  • transparent
  • transparency
background-color:transparent;
bl
  • border left
  • left border
border-left:1px solid black;
bl.border-left:1px dotted black;
bl2border-left:2px solid black;
bl3border-left:3px solid black;
bldborder-left:4px double black;
bltborder-left:0px solid transparent;
blt1border-left:1px solid transparent;
bn
  • border none
  • no border
border:none;
br
  • border right
  • right border
border-right:1px solid black;
br.border-right:1px dotted black;
br2border-right:2px solid black;
br2.border-right:2px dotted black;
br3border-right:3px solid black;
brdborder-right:4px double black;
brtborder-right:0px solid transparent;
brt1border-right:1px solid transparent;
bt
  • border top
  • top border
border-top:1px solid black;
bt.border-top:1px dotted black;
bt2border-top:2px solid black;
bt3border-top:3px solid black;
btdborder-top:4px double black;
bttborder-top:0px solid transparent;
btt1border-top:1px solid transparent;
cap
  • capitalise
  • capitalize
text-transform:capitalize;
ffnfont-family:sans-serif;
ffsfont-family:serif;
fll
  • float left
float:left;
flr
  • float right
float:right;
fs058
  • xx-smaller
  • xxs
font-size:58%;
fs069
  • x-smaller
  • xs
font-size:69%;
fs080
  • sm80
font-size:80%;
fs083
  • smaller
  • sm
font-size:83%;
fs085
  • sm85
font-size:85%;
fs090
  • sm90
font-size:90%;
fs092
  • sm92
font-size:92%;
fs095
  • sm95
font-size:95%;
fs105font-size:105%;
fs110
  • sm110
font-size:110%;
fs120
  • larger
  • lg
font-size:120%;
fs144
  • x-larger
  • xl
font-size:144%;
fs182
  • xx-larger
  • 2xl
  • xxl
font-size:182%;
fs207
  • xxx-larger
  • 3xl
font-size:207%;
fs249
  • xxxx-larger
  • 4xl
font-size:249%;
fs260font-size:260%;
fs280font-size:280%;
fs300font-size:300%;
fsi
  • italic
  • i
font-style:italic;
fsn
  • roman
font-style:normal;
fvnfont-variant:normal;
fwb
  • bold
  • b
font-weight:bold;
fwn
  • normal
font-weight:normal;
itpadding-left:2em; text-indent:-2em;
it1padding-left:1em; text-indent:-1em;
it1p.5padding-left:1.5em; text-indent:-1em;
it1p2padding-left:3em; text-indent:-1em;
it42padding-left:4em; text-indent:-2em;
itppadding-left:2em; text-indent:-1em;
itp.5padding-left:2.5em; text-indent:-2em;
lc
  • lower case
  • lower-case
  • lowercase
text-transform:lowercase;
lh100
  • lh1
  • lh10
line-height:100%;
lh110
  • lh11
line-height:110%;
lh120
  • lh12
line-height:120%;
lh130
  • lh13
line-height:130%;
lh150
  • lh15
line-height:150%;
lh200
  • lh2
  • lh20
line-height:200%;
lh250
  • lh25
line-height:250%;
lh300
  • lh3
line-height:300%;
lh90
  • lh9
line-height:90%;
lh95line-height:95%;
mamargin-right:auto; margin-left:auto;
ma10margin:10px;
ma5margin:5px;
mb10margin-bottom:10px;
mb5margin-bottom:5px;
mc
  • float
  • float center
  • float centre
margin:0 auto 0 auto;
ml10margin-left:10px;
ml5margin-left:5px;
mr10margin-right:10px;
mr5margin-right:5px;
mt10margin-top:10px;
mt5margin-top:5px;
pb.5padding-bottom:0.5em;
pb0padding-bottom:0;
pb1padding-bottom:1em;
pb15padding-bottom:1.5em;
pb2padding-bottom:2em;
pb3padding-bottom:3em;
pb4padding-bottom:4em;
pb5padding-bottom:5em;
pb6padding-bottom:6em;
pb7padding-bottom:7em;
pl.5padding-left:0.5em;
pl0padding-left:0;
pl1padding-left:1em;
pl15padding-left:1.5em;
pl2padding-left:2em;
pl2.5padding-left:2.5em;
pl3padding-left:3em;
pl3.5padding-left:3.5em;
pl4padding-left:4em;
pl5padding-left:5em;
pl6padding-left:6em;
pl7padding-left:7em;
pr.5padding-right:0.5em;
pr0padding-right:0;
pr1padding-right:1em;
pr15padding-right:1.5em;
pr2padding-right:2em;
pr2.5padding-right:2.5em;
pr3padding-right:3em;
pr3.5padding-right:3.5em;
pr4padding-right:4em;
pr5padding-right:5em;
pr6padding-right:6em;
pr7padding-right:7em;
pt.5padding-top:0.5em;
pt0padding-top:0;
pt1padding-top:1em;
pt15padding-top:1.5em;
pt2padding-top:2em;
pt3padding-top:3em;
pt4padding-top:4em;
pt5padding-top:5em;
pt6padding-top:6em;
pt7padding-top:7em;
ptb.5padding-top:0.5em; padding-bottom:0.5em;
ptb1padding-top:1em; padding-bottom:1em;
rtldirection:rtl;
sc
  • small caps
  • small capitals
font-variant:small-caps;
tds
  • strike
text-decoration:line-through;
tdu
  • underline
text-decoration:underline;
uc
  • upper case
  • upper-case
  • uppercase
text-transform:uppercase;
vbm
  • vertical align bottom
  • bottom
vertical-align:bottom;
vbs
  • vertical align baseline
  • baseline
vertical-align:baseline;
vmi
  • vertical align middle
  • middle
vertical-align:middle;
vtb
  • vertical align text bottom
  • text bottom
vertical-align:text-bottom;
vtp
  • vertical align top
  • top
vertical-align:top;
vtt
  • vertical align text top
  • text top
vertical-align:text-top;
w0
  • width narrow
  • narrow
width:0;
w10width:10%;
w100width:100em;
w15width:15%;
w20width:20%;
w25
  • quarter width
  • quarter
width:25%;
w30width:30%;
w33
  • third width
  • third
width:33%;
w40width:40%;
w5width:5%;
w50
  • half width
  • half
width:50%;
w60width:60%;
w67
  • two thirds width
  • two thirds
  • two-thirds
  • two third
  • two-third
width:67%;
w70width:70%;
w75
  • three quarter width
  • three quarter
  • three-quarter
  • three quarters
  • three-quarters
width:75%;
w80width:80%;
w90width:90%;
wa
  • width all
  • full width
  • full
width:100%;
wnw
  • nowrap
white-space:nowrap;

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:top; 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.