Template:Col-begin/doc

shortcut: {{C-s}}
From wikiNonStop
Revision as of 01:42, 3 April 2024 by en>Izno (adj language)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Not to be confused with [[:{{{1}}}]].


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 1st column)
  • {{col-break}}: triggers the start of each column
  • {{col-end}}: ends the multi-column table.

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

Usage

{{col-begin|width=70%}}: start table with specific width.
{{col-break|width=66%}}: start column-1 as 66% wide.
This is text in column-1.
{{col-break|width=33%}}: start column-2 as 33% wide.
This is text in column-2.
{{col-end}}

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

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 screen. 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 like this:

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

Examples

Here are some example codes that you can use to make columns of text in your Wikipedia article. You can change the width of your columns by changing the code words that go between the text of your columns. Good luck!

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}}

gives:

Example 2, using col-2
{{col-begin}}
{{col-2}}
{| class="wikitable" style="width:18em"
|+ Production by year
|-
! 1980
| 50,000
|-
! 1990
| 75,000
|-
! 2000
| 90,000
|}
{{col-2}}
{| class="wikitable" style="width:18em"
|+ Profit by year
|-
! 1980
| $6,000
|-
! 1990
| $7,500
|-
! 2000
| $8,200
|}
{{col-end}}

gives:

Template:Col-2
Production by year
1980 50,000
1990 75,000
2000 90,000

Template:Col-2

Profit by year
1980 $6,000
1990 $7,500
2000 $8,200

Example 3, use 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}}

gives:

Example 4, use col-break with auto outer width
{{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}}
Example 5, Lots of columns, 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-break}}
{| class="wikitable" style="width:18em"
|+ Revenue by product
|-
! Widgets
| $25,000
|-
! Foos
| $65,500
|-
! Bars
| $28,000
|}
{{col-end}}

gives:

See also

Column-generating template families

The templates listed here are not interchangeable. For example, using {{Col-float }} with {{Col-end }} instead of {{Col-float-end }} would leave a ‎<div>...‎</div> open, potentially harming any subsequent formatting.

Column templates
Type Family
Handles wiki
table code?
Responsive/
mobile suited
Start template Column divider End template
Float "col-float" Yes Yes {{Col-float }} {{Col-float-break }} {{Col-float-end }}
"columns-start" Yes Yes {{Columns-start }} {{Column }} {{Columns-end }}
Columns "div col" Yes Yes {{Div col }} {{Div col end }}
"columns-list" No Yes {{Columns-list }} (wraps div col)
Flexbox "flex columns" No Yes {{Flex columns }}
Table "col" Yes No {{Col-begin }},
{{Col-begin-fixed }} or
{{Col-begin-small }}
{{Col-break }} or
{{Col-2 }} .. {{Col-5 }}
{{Col-end }}

Can template handle the basic wiki markup {| | || |- |} used to create tables? If not, special templates that produce these elements (such as {{(! }}, {{! }}, {{!! }}, {{!- }}, {{!) }})—or HTML tags (‎<table>...‎</table>, ‎<tr>...‎</tr>, etc.)—need to be used instead.

TemplateData

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

Col-begin

This template starts a multi-column table.

Template parameters

ParameterDescriptionTypeStatus
Table widthwidth

The width of the complete table, defined as a percent (i.e. 50%), typically no more than 95%

Stringoptional