Difference between revisions of "Template:Aligned table/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>SMcCandlish
(→‎Parameters: example)
blackwiki>SMcCandlish
(→‎Parameters: markup clean-up)
Line 60: Line 60:
 
  | cols
 
  | cols
 
  | Number of columns in the table.
 
  | Number of columns in the table.
  | <nowiki> |cols=4 </nowiki>
+
  | <code><nowiki> |cols=4 </nowiki></code>
 
  | 2
 
  | 2
  
 
  | fullwidth
 
  | fullwidth
 
  | {{nowrap|Set to anything ("on", "true", "yes", etc) to ensure table spans entire width available.}}<br />(Effect is to remove border-spacing and add width:100% to the table's styling.)
 
  | {{nowrap|Set to anything ("on", "true", "yes", etc) to ensure table spans entire width available.}}<br />(Effect is to remove border-spacing and add width:100% to the table's styling.)
  | <nowiki> |fullwidth=on </nowiki>
+
  | <code><nowiki> |fullwidth=on </nowiki></code>
 
  | ''not set''
 
  | ''not set''
  
 
  | class
 
  | class
 
  | CSS/[[HTML attribute|HTML class]]/es applied to the table.
 
  | CSS/[[HTML attribute|HTML class]]/es applied to the table.
  | <nowiki> |class=wikitable &nbsp; |class=infobox</nowiki><br /><nowiki>|class=sortable nowrap &nbsp; |class=sidebar</nowiki>
+
  | <code><nowiki> |class=wikitable &nbsp; |class=infobox</nowiki><br /><nowiki>|class=sortable nowrap &nbsp; |class=sidebar</nowiki></code>
 
  | ''none''
 
  | ''none''
  
 
  | style
 
  | style
 
  | [[CSS styling]] applied to the table.
 
  | [[CSS styling]] applied to the table.
  | {{nowrap|<nowiki> |style=width:80%;background:transparent; </nowiki>}}
+
  | <code>{{nowrap|<nowiki> |style=width:80%;background:transparent; </nowiki>}}</code>
 
  | ''none''
 
  | ''none''
  
 
  | colwidth
 
  | colwidth
 
  | Width of each column (or include "width:...;" in <kbd>colstyle</kbd>).
 
  | Width of each column (or include "width:...;" in <kbd>colstyle</kbd>).
  | <nowiki> |colwidth=6.0em &nbsp; |colwidth=25%</nowiki>
+
  | <code><nowiki> |colwidth=6.0em &nbsp; |colwidth=25%</nowiki></code>
 
  | ''not set''
 
  | ''not set''
  
Line 90: Line 90:
 
  | colstyle
 
  | colstyle
 
  | CSS styling applied to each column.
 
  | CSS styling applied to each column.
  | <nowiki> |colstyle=background:transparent; </nowiki>
+
  | <code><nowiki> |colstyle=background:transparent; </nowiki></code>
 
  | "
 
  | "
  
 
  | rowstyle
 
  | rowstyle
 
  | CSS styling applied to each row.
 
  | CSS styling applied to each row.
  | <nowiki> |rowstyle=text-align:center; </nowiki>
+
  | <code><nowiki> |rowstyle=text-align:center; </nowiki></code>
 
  | "
 
  | "
  
Line 101: Line 101:
 
  | leftright
 
  | leftright
 
  | Set to anything ("on", "true", "yes", etc) in place of <kbd><nowiki>|col1align=left</nowiki></kbd> and <kbd><nowiki>|col2align=right</nowiki></kbd>
 
  | Set to anything ("on", "true", "yes", etc) in place of <kbd><nowiki>|col1align=left</nowiki></kbd> and <kbd><nowiki>|col2align=right</nowiki></kbd>
  | <nowiki> |leftright=on </nowiki>
+
  | <code><nowiki> |leftright=on </nowiki></code>
 
  | ''not set''
 
  | ''not set''
  
 
  | col[C]width
 
  | col[C]width
 
  | Width of column number [C] (or include "width:...;" in <kbd>col[C]style</kbd>).
 
  | Width of column number [C] (or include "width:...;" in <kbd>col[C]style</kbd>).
  | <nowiki> |col2width=9.0em &nbsp; |col3width=35%</nowiki>
+
  | <code><nowiki> |col2width=9.0em &nbsp; |col3width=35%</nowiki></code>
 
  | ''none set''
 
  | ''none set''
  
 
  | col[C]class
 
  | col[C]class
 
  | Class/es applied to column number [C].
 
  | Class/es applied to column number [C].
  | <nowiki> |col1class=navbox-group </nowiki>
+
  | <code><nowiki> |col1class=navbox-group </nowiki></code>
 
  | "
 
  | "
  
 
  | col[C]align
 
  | col[C]align
 
  | Alignment (left{{\}}right{{\}}center) for column [C]'s cell contents (or include "text-align:...;" in <kbd>col[C]style</kbd>).
 
  | Alignment (left{{\}}right{{\}}center) for column [C]'s cell contents (or include "text-align:...;" in <kbd>col[C]style</kbd>).
  | <nowiki> |col4align=right </nowiki>
+
  | <code><nowiki> |col4align=right </nowiki></code>
 
  | ''none set''
 
  | ''none set''
  
 
  | col[C]nowrap
 
  | col[C]nowrap
 
  | Set to anything ("on", "true", "yes", etc) to add "white-space:nowrap;" to column [C]'s cell styling (i.e. to prevent lines within its cells from wrapping; or include "nowrap" in <kbd>col[C]class</kbd> or "white-space:nowrap;" in <kbd>col[C]style</kbd>).
 
  | Set to anything ("on", "true", "yes", etc) to add "white-space:nowrap;" to column [C]'s cell styling (i.e. to prevent lines within its cells from wrapping; or include "nowrap" in <kbd>col[C]class</kbd> or "white-space:nowrap;" in <kbd>col[C]style</kbd>).
  | <nowiki> |col5nowrap=on </nowiki>
+
  | <code><nowiki> |col5nowrap=on </nowiki></code>
 
  | "
 
  | "
  
 
  | col[C]style
 
  | col[C]style
 
  | CSS styling applied to column number [C].
 
  | CSS styling applied to column number [C].
  | <nowiki> |col4style=font-style:italic; </nowiki>
+
  | <code><nowiki> |col4style=font-style:italic; </nowiki></code>
 
  | "
 
  | "
  
Line 132: Line 132:
 
  | row[R]class
 
  | row[R]class
 
  | Class/es applied to row number [R].
 
  | Class/es applied to row number [R].
  | <nowiki> |row10class=navbox-abovebelow </nowiki>
+
  | <code><nowiki> |row10class=navbox-abovebelow </nowiki></code>
 
  | ''none set''
 
  | ''none set''
  
 
  | row[R]style
 
  | row[R]style
 
  | CSS styling applied to row number [R].
 
  | CSS styling applied to row number [R].
  | <nowiki> |row2style=font-weight:bold; </nowiki>
+
  | <code><nowiki> |row2style=font-weight:bold; </nowiki></code>
 
  | "
 
  | "
  
 
  | row[R]header
 
  | row[R]header
 
  | Set to any value (e.g. <code>Y</code>) to change row's cells from data cells to table headers (headings).
 
  | Set to any value (e.g. <code>Y</code>) to change row's cells from data cells to table headers (headings).
  | <nowiki> |row1header=on </nowiki>
+
  | <code><nowiki> |row1header=on </nowiki></code>
 
  | ''not set''
 
  | ''not set''
  
Line 148: Line 148:
 
  | class[R].[C]
 
  | class[R].[C]
 
  | Class/es applied to cell in row [R], column [C]. Overrides any other class attributions (<kbd>row[R]class</kbd>, <kbd>col[C]class</kbd>).
 
  | Class/es applied to cell in row [R], column [C]. Overrides any other class attributions (<kbd>row[R]class</kbd>, <kbd>col[C]class</kbd>).
  | <nowiki> |class1.2=adr </nowiki>
+
  | <code><nowiki> |class1.2=adr </nowiki></code>
 
  | ''none set''
 
  | ''none set''
  
 
  | style[R].[C]
 
  | style[R].[C]
 
  | CSS styling applied to cell in row [R], column [C]. Overrides any more general styling (<kbd>leftright</kbd>, <kbd>col[C]align</kbd>, <kbd>row[R]style</kbd>, etc).
 
  | CSS styling applied to cell in row [R], column [C]. Overrides any more general styling (<kbd>leftright</kbd>, <kbd>col[C]align</kbd>, <kbd>row[R]style</kbd>, etc).
  | <nowiki> |style5.3=text-align:right; </nowiki>
+
  | <code><nowiki> |style5.3=text-align:right; </nowiki></code>
 
  | "
 
  | "
  
 
  | {{sans-serif|''Unnamed parameters''}}
 
  | {{sans-serif|''Unnamed parameters''}}
 
  | Each unnamed parameter is taken to be the next cell in the table, starting at the table's top left corner and working left to right from top to bottom.
 
  | Each unnamed parameter is taken to be the next cell in the table, starting at the table's top left corner and working left to right from top to bottom.
  | {{!}} Azerbaijan {{!}} Malta {{!}} Zaire
+
  | <code>{{!}} Azerbaijan {{!}} Malta {{!}} Zaire</code>
 
  | empty
 
  | empty
 
}}
 
}}

Revision as of 18:37, 18 July 2015

The purpose is of this template is for generating simple tables in locations where standard table markup is either not possible, without significant use of the {{!}} magic word (e.g., with a {{sidebar}} template), or cumbersome (due to the repetitive use of specification of the same style statement in each row). This template should not be used to replace standard table markup in articles. This template is meant to be complimentary to {{infobox}} or {{sidebar}}, and not a replacement for {{infobox}} or {{sidebar}}.

A simpler method to include a table in a template that does not directly support table markup is to create the table in a sub-template using standard markup and transclude it.

Full syntax

For parameter explanations, see table below.

{{Aligned table
| cols =
| fullwidth =
| class =
| style =
| colwidth =
<!--| colclass = -->
| leftright =
| colstyle =
| rowstyle =

<!--for Cth column:-->
| colCwidth =
| colCclass =
| colCalign =
| colCstyle =
| colCnowrap =

<!--for Rth row:-->
| rowRclass =
| rowRstyle =
| rowRheader =

<!--for cell R,C:-->
| classR.C =
| styleR.C =

| (cell 1,1) | (cell 1,2) | ... | ...
| (cell 2,1) | (cell 2,2) | ... | ...
}}

Parameters

Script error: No such module "aligned table".

Examples

{{Aligned table
|cols=3 |class=wikitable
| A | 1 | a
| B | 2 | b
}}

Script error: No such module "aligned table".

{{Aligned table
|cols=4 |class=wikitable
|col1align=center |col2align=center
|col3align=right  |col4align=right
| AAA | aa    | 123  | 12345
| B   | bbbbb | 1234 | 2
}}

Script error: No such module "aligned table".

{{Aligned table
|class=wikitable |style=width:20em;
|col1align=center |col2align=right
| AAA | 123
| B   | 2
}}

Script error: No such module "aligned table".

{{Aligned table
|cols=3 |class=wikitable sortable
|row1header=y
| U | # | l
| A | 1 | a
| B | 2 | b
}}

Script error: No such module "aligned table".