Jump to content

Template:Col-end

From Wikidata
Documentation icon Template documentation[view · edit · history · purge ]

The {{Col-begin}}, {{Col-break}} and {{Col-end}} templates control columns of text on a page:

  • {{Col-begin}} starts a table (followed by {{Col-break}} for the 1st column)
  • {{Col-break}} triggers the start of each subsequent column, and
  • {{Col-end}} ends the multi-column table.

The widths of columns can be specified by using various additional codes; see below for examples.

Usage

[edit]

{{Col-begin|width=70%}}: Start table with specific width.
{{Col-break|width=67%}}: Start first column as 67% wide.
This is text in column 1.
{{Col-break|width=33%}}: Start second column as 33% wide.
This is text in column 2.
{{Col-end}}

The table will have two columns, with the first column twice (2×) the width of the second column.

A border of 2px (1px width on each side) corresponds to a 5%. Therefore, with a 2px border, the width needs to be 95% for the table to fit within the viewport. Since it's possible that some tables might not have a border, correction on the individual page could be made after substitution. Another way to create a two column table is as follows:

{{Col-begin|width=95%}}
 |-
 |
Left column
 |
Right column
|}

When more columns are needed, the following syntax is used:

Examples

[edit]
Example 1: Using {{Col-break}}
{{Col-begin}}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Production by year
 ! 1980
 | 50,000
 |-
 ! 1990
 | 75,000
 |-
 ! 2000
 | 90,000
|}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Profit by year
 ! 1980
 | $6,000
 |-
 ! 1990
 | $7,500
 |-
 ! 2000
 | $8,200
|}
{{Col-end}}

     …which renders as…

Example 2: Using {{Col-break}} with specified widths
{{Col-begin}}
{{Col-break|width=80%}}
{| class="wikitable" style="width: 18em;"
 |+ Production by year
 ! 1980
 | 50,000
 |-
 ! 1990
 | 75,000
 |-
 ! 2000
 | 90,000
|}
{{Col-break|width=20%}}
{| class="wikitable" style="width: 18em;"
 |+ Profit by year
 ! 1980
 | $6,000
 |-
 ! 1990
 | $7,500
 |-
 ! 2000
 | $8,200
|}
{{Col-end}}

     …which renders as…

Example 3: Using {{Col-break}} with 'auto' outer width and gap parameter
{{Col-begin|width=auto}}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Production by year
 ! 1980
 | 50,000
 |-
 ! 1990
 | 75,000
 |-
 ! 2000
 | 90,000
|}
{{Col-break|gap=2em}}
{| class="wikitable" style="width: 18em;"
 |+ Profit by year
 ! 1980
 | $6,000
 |-
 ! 1990
 | $7,500
 |-
 ! 2000
 | $8,200
|}
{{Col-end}}

     …which renders as…

Example 4: Using {{Col-break}} for three columns
{{Col-begin}}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Production by year
 ! 1980
 | 50,000
 |-
 ! 1990
 | 75,000
 |-
 ! 2000
 | 90,000
|}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Profit by year
 ! 1980
 | $6,000
 |-
 ! 1990
 | $7,500
 |-
 ! 2000
 | $8,200
|}
{{Col-break}}
{| class="wikitable" style="width: 18em;"
 |+ Revenue by product
 ! Widgets
 | $25,000
 |-
 ! Foos
 | $65,500
 |-
 ! Bars
 | $28,000
|}
{{Col-end}}

     …which renders as…

TemplateData

[edit]
This is the TemplateData documentation for this template used by VisualEditor and other tools.

Col-end

This template starts a multi-column table.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Table widthwidth

The width of the complete table as a percentage

Example
auto to display with minimum width; 50%, typically no more than 95%
Stringoptional
Background colorbgcolor bgColor

Set the background color of the table

Example
linen
Stringoptional
CSS classclass

Extra class beyond "col-begin"

Stringoptional
CSS stylestyle

Extra CSS

Stringoptional
Border styleborder

CSS border style

Stringoptional
Small textsmall

Set for smaller text

Stringoptional

See also

[edit]