Jump to content

Template:Div col/doc

From Simple English Wikipedia, the free encyclopedia

{{Div col}} can be used to make a list into columns that wrap properly and compatibly with portable computer devices, esp. PAD operating systems and small screens. It automatically breaks the available space into equal spaces, meaning, for instance, that it is not necessary to work out the halfway point, or the one-third & two-thirds points between two columns.

  • The list content is either provided by the |content= parameter (which can be restrictive of what content is allowed; e.g., wiki markup like | must somehow be escaped) or terminated with {{div col end}}. The {{columns-list}} wrapper uses the parameter method for providing content (including its limitations).
  • The template system (family) also offers parameter options to set a smaller (90%) font-size parameter (|small=yes), place vertical lines parameter ("rules") between the columns (|rules=) and to add other custom styling parameter (|style=).

{{Div col}} can create multiple columns in web browsers which support one of the following CSS properties:

There are six parameters for this template and their usage is described below.

|cols= or first unnamed parameter
(Now deprecated, as colwidth below is better suited to flexible formatting for a variety of display screen sizes (from mobile phones, tablets, etc to widescreen cinema-style displays))
Specifies the number of columns (default 2).
|colwidth= or second unnamed parameter
Specifies the minimum width of the columns and determines automatically the number of columns based on screen width (i.e. more columns will be shown on wider displays). Overrides cols. Can be specified in any CSS unit, for instance in em, about the width of a capital "M", e.g, colwidth=20em
|rules=
Adds vertical lines ("rules") between the columns if set to yes or some CSS styling (e.g. 1px dashed blue;).
|gap=
Specifies the space between the content of adjacent columns. Specified in any CSS unit, e.g, gap=2em. The default spacing (set by browser) is 1em.
|style=
CSS styling to apply to the columns.
|content=
content to apply to the columns.

Examples

[change source]

Usage without parameters

[change source]

Usage of fixed column counts is deprecated, therefore this example should no longer be used as well.

Example with no parameters produces two columns as the default is two columns.
{{Div col}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage with named parameters

[change source]

When parameters are named in the template, they can be used in any order. Example:

{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

or

{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

and exactly the same result below

  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage of parameters without naming the parameters

[change source]

When parameters are not named then template considers first unnamed parameter to be "cols", second unnamed parameter to be "colwidth", remaining unnamed parameters (e.g. third, fourth, fifth, etc. unnamed parameter) will be ignored by the template without providing an error message. The first and second parameter "cols" and "colwidth" could be unnamed but all other parameters (such as "rules", "gap", "style" and "small") must always be named in the template.

Example with correct usage of unnamed parameters

Note the empty column for the "number of columns" between "Div col" and "10em".

{{div col||10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Example with incorrect usage of unnamed parameters

Note that the unnamed third, fourth and fifth parameters will be ignored by the template. If used, then third, fourth and fifth parameters must always be named.

{{div col||10em|yes|2em|yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces (unnamed third, fourth and fifth parameters are ignored)
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage of "cols" parameter

[change source]

Important: Use of now-deprecated "cols" parameter is discouraged, leave it blank and instead use the "colwidth" parameter.

Example with 3 columns
{{Div col|3}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example with 4 columns
{{Div col|4}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage of "colwidth" parameter

[change source]

Important: The usage of the previous parameter "cols" is deprecated. It is strongly recommended to not use now-deprecated "cols" parameter (please leave it blank) and instead use "colwidth" parameter.

Example with column width of 10em
Note the empty column for the "number of columns" between "Div col" and "10em".
{{div col||10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example with column width of 20em
{{div col||20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example with column width of 30em
{{div col||30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example of how this template behaves if no bullets (generated by asterisk mark) are used.
{{div col||10em}}
a
b
c
d
e
f
g
h
{{div col end}}
produces

a b c d e f g h

Usage of "rules" parameter

[change source]
Example
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Usage of "gap" parameter

[change source]
Example
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Usage of "small" parameter

[change source]
Example showing how setting "small" parameter to "yes" produces smaller font size
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage of "content" parameter

[change source]
Example showing how to provide "content" parameter without using {{Div col end}}
{{Div col|colwidth=10em|content=
* a
* b
* c
* d
* e
* f
* g
* h
}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

TemplateData

[change source]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Div col in articles based on its TemplateData.

TemplateData for Div col

Breaks a list into columns. It automatically breaks each column to an equal space, so you do not manually have to find the half way point on two columns. The list is provided by |content= or closed with {{div col end}}.

Template parameters

ParameterDescriptionTypeStatus
colscols 1

Specifies the number of columns.

Default
2
Numberdeprecated
Column widthcolwidth 2

Specifies the width of columns, and determines dynamically the number of columns based on screen width; more columns will be shown on wider displays. This overrides the 'cols' setting.

Example
30em
Stringsuggested
Rulesrules

Produces vertical rules between the columns if set to yes.

Example
'yes' or '1px dashed blue'
Stringoptional
Gap sizegap

Specifies the space between the content of adjacent columns.

Example
2em
Stringoptional
CSS stylestyle

Specifies any custom styling.

Stringoptional
Contentcontent

Specifies the content to divide into columns

Stringoptional
Small fontsmall

Use a smaller font size (90%)

Default
no
Example
yes
Booleanoptional

Redirects

[change source]