Tables

PmWiki ; , table directive . Cookbook:Rowspan in simple tables Cookbook:Formatting tables

: ||

 || 
|| border=1
|| cell 1 || cell 2 || cell 3 ||
|| cell 1 || cell 2 ||
cell 1cell 2cell 3
cell 1cell 2
 '  '  !! !!! 
|| border=1
||! cell 1 ||! cell 2 ||! cell 3 ||
|| cell 1  ||  cell 2 ||  cell 3 ||
cell 1cell 2cell 3
cell 1cell 2cell 3

, ||! !||

|| border=1
||!   !||
||! cell 1 ||! cell 2 ||! cell 3 ||
|| cell 1  ||  cell 2 ||  cell 3 ||
cell 1cell 2cell 3
cell 1cell 2cell 3

  • ||
  • ||
|| border=1 width=100%
||!cell 1      ||! cell 2  ||!       cell 3||
||        ||       ||         ||
cell 1cell 2cell 3
   
|| border=1 width=100%
||!cell default||!cell left ||
||default-aligned||left-aligned ||
cell defaultcell left
default-alignedleft-aligned

(.)

Column spanning
|| border=1 width=100%
|| |||| right column ||
|| || middle column ||||
|| left column ||||||
|| left column || middle column || right column ||
 right column
 middle column
left column
left columnmiddle columnright column

 ||  ||   (HTML<table>)

 width= ,  *.
Table width
|| border=1 width=100% 
|| cell 1 || cell 2 || cell 3 ||
|| c1 || cellcellcellcell2 || cell 3 ||
cell 1cell 2cell 3
c1cellcellcellcell2cell 3

border=

|| border=10 width=70%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
cell 1cell 2cell 3
   
|| border=0 width=70%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
cell 1cell 2cell 3
   
 align=center, align=left,  align=right  align=left  align=right   
:
|| border=1 align=center width=50%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
 "align=center" 
cell 1cell 2cell 3
   
 "align=center" 
:
|| border=1 align=left width=50%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
 "align=left" 
cell 1cell 2cell 3
   
 "align=left" 
:
|| border=1 align=right width=50%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
 "align=right" 
cell 1cell 2cell 3
   
 "align=right" 

: ("") CSS

||style="margin-left:0px;"

bgcolor=( Cookbook:FormattingTables).

|| border=1 align=center bgcolor=yellow width=70%
||!cell 1 ||! cell 2 ||! cell 3||
|| ||  || ||
cell 1cell 2cell 3
   

How do I create a basic table?

Tables are created via use of the double pipe character: ||. Lines beginning with this markup denote rows in a table; within such lines the double-pipe is used to delimit cells. In the examples below a border is added for illustration (the default is no border).

Basic table
|| border=1 rules=rows frame=hsides
|| cell 1 || cell 2 || cell 3 ||
|| cell 1 || cell 2 || cell 3 ||
cell 1cell 2cell 3
cell 1cell 2cell 3

How do I create cell headers?

Header cells can be created by placing ! as the first character of a cell. Note that these are table headers, not headings, so it doesn't extend to !!, !!!, etc.

Table headers
|| border=1 rules=cols frame=vsides
||! cell 1 ||! cell 2 ||! cell 3 ||
|| cell 1  ||  cell 2 ||  cell 3 ||
cell 1cell 2cell 3
cell 1cell 2cell 3

How do I obtain a table with thin lines and more distance to the content?

"Thin lines" is tricky and browser dependent, but the following works for Firefox and IE (Nov. 2009):

Thin lines and cell padding
||border="1" bordercolordark="black" bordercolorlight="black" style="border-collapse:collapse" cellpadding="5" width=66%
||!Header || !Header|| '''Header'''||
||cells   || with   ||      padding||
||        ||        ||             ||
Header!HeaderHeader
cellswithpadding
   

How do I create an advanced table?

See table directives

My tables are by default centered. When I try to use '||align=left' they don't align left as expected.

Use ||style="margin-left:0px;" instead.

How can I specify the width of columns?

You can define the widths via custom styles, see Cookbook:FormattingTables and $TableCellAttrFmt. Add in config.php : $TableCellAttrFmt = 'class=col\$TableCellCount';

And add in pub/css/local.css :
table.column td.col1 { width: 120px; }
table.column td.col3 { width: 40px; }

How can I display a double pipe "||" in cell text using basic table markup?

Escape it with [=||=] to display || unchanged.

How to I apply styles to the elements of the table, like an ID to the table row, or a class/style to the TD?

See $WikiStyleApply.