Help:Lists - MediaWiki
Jump to content
From mediawiki.org
Translate this page
Languages:
Bahasa Indonesia
Nederlands
Qaraqalpaqsha
Yorùbá
català
italiano
norsk bokmål
polski
português
slovenčina
suomi
svenska
čeština
русский
العربية
فارسی
中文
한국어
Note:
When you edit this page, you agree to release your contribution under the
CC0
. See
Public Domain Help Pages
for more info.
Some old revisions for this page were imported under CC BY-SA license. Only new contributions are PD.
This page deals with creating lists in MediaWiki.
List basics
edit
MediaWiki
offers three types of lists:
unordered lists
ordered lists
and
definition
lists.
Basically
edit
Unordered lists
Each item is on a new line starting with an asterisk
e.g.
* item
Ordered lists
Each item is on a new line starting with a hash
e.g.
# item
Definition lists
Each item has two parts: the
term
and the
description
The
term
is on a new line starting with a semicolon
e.g.
; term
The
description
follows on the same line after a colon
e.g.
; term : description
or the
description
starts its own line with a colon
e.g.
: description
(there can be several descriptions per term, each one starting with a colon on a new line).
A little bit further
edit
In the following table you will find some examples for both methods:
Wikitext
Rendering
* Lists are easy to do:
** start every line
* with a star
** more stars mean
*** deeper levels
Lists are easy to do:
start every line
with a star
more stars mean
deeper levels
* A newline
* in a list
marks the end of the list.
Of course
* you can
* start again.
A newline
in a list
marks the end of the list.
Of course
you can
start again.
# Numbered lists are good
## very organized
## easy to follow
Numbered lists are good
very organized
easy to follow
* You can also
** break lines
inside lists
like this
You can also
break lines
inside lists
like this
; Definition lists
; term : definition
; semicolon plus term
: colon plus definition
Definition lists
term
definition
semicolon plus term
colon plus definition
; Mixed definition lists
; item 1 : definition
:; sub-item 1 plus term
:: two colons plus definition
:; sub-item 2 : colon plus definition
; item 2
: back to the main list
Mixed definition lists
item 1
definition
sub-item 1 plus term
two colons plus definition
sub-item 2
colon plus definition
item 2
back to the main list
* Or create mixed lists
*# and nest them
*#* like this
*#*; definitions
*#*: work:
*#*; apple
*#*; banana
*#*: fruits
Or create mixed lists
and nest them
like this
definitions
work:
apple
banana
fruits
Multiple line in lists
edit
For simplicity, list items in wiki markup cannot be longer than a paragraph. A following blank line will end the list and reset the counter on ordered lists. Separating unordered list items usually has no noticeable effects.
Paragraphs can be forced in lists by using HTML tags.
If you want to put more than one line of text, add two line break symbols,
br
/><
br
/>
, and you will get the desired effect.
Wrapping text in
‎<
...
will render that text in a new paragraph, which will start on its own line when rendered.
Continuing a list item after a sub-item
edit
MediaWiki does not support continuing a list item after a sub-list
, unless the whole list is marked up with HTML.
Workarounds
edit
In the case of an unnumbered first-level list in wikitext code this limitation can be overcome by splitting the list into multiple lists; indented text between the partial lists may visually serve as part of a list item after a sublist; however:
This is semantically different
This may display (depending on CSS) unwanted vertical space between each list (in which case, for uniformity, every first-level list item could be made a separate list)
This causes numbering to restart from 1 in numbered lists.
Wikitext
Rendering
ol
li
list item A1
ol
li
list item B1
li
li
list item B2
li
ol
continuing list item A1
li
li
list item A2
li
ol
list item A1
list item B1
list item B2
continuing list item A1
list item A2
vs.
# list item A1
## list item B1
## list item B2
#: continuing list item A1
# list item A2
list item A1
list item B1
list item B2
continuing list item A1
list item A2
One level deeper, with a sublist item continuing after a sub-sublist, one gets even more blank lines; however, the continuation of the first-level list is not affected:
Wikitext
Rendering
# list item A1
## list item B1
### list item C1
##: continuing list item B1
## list item B2
# list item A2
list item A1
list item B1
list item C1
continuing list item B1
list item B2
list item A2
See also
m:Template:List demo
Changing the list type
edit
Per list
edit
The list type (which type of marker appears before the list item) can be changed in CSS by setting the
list-style-type
property:
Wikitext
Rendering
ol
style
"list-style-type:lower-roman"
li
About the author
li
li
Foreword to the first edition
li
li
Foreword to the second edition
li
ol
About the author
Foreword to the first edition
Foreword to the second edition
ol
style
"list-style-type:lower-alpha"
li
About the author
li
li
Foreword to the first edition
li
li
Foreword to the second edition
li
ol
About the author
Foreword to the first edition
Foreword to the second edition
Site-wide
edit
The standard #, ##, ### wikitext can be used alongside CSS in
MediaWiki:Common.css
to produce the usual system of numbered lists (1, 2, 3; then a, b, c; then i, ii, iii):
ol
list-style-type
decimal
ol
li
ol
list-style-type
lower-alpha
ol
li
ol
li
ol
list-style-type
lower-roman
The first
ol
above is the default, so not necessary unless some other list-style-type is required.
Wikitext
Rendering
#list item A1
##list item B1
###list item C1
###list item C2
##list item B2
#list item A2
list item A1
list item B1
list item C1
list item C2
list item B2
list item A2
Extra indentation of lists
edit
In a numbered list in a large font, some browsers do not show more than two digits, unless extra indentation is applied (if there are multiple colons: for each colon). This can be done with CSS:
ol
margin-left
cm
or alternatively, like below.
Wikitext
Rendering
Comments
:#abc
:#def
:#ghi
abc
def
ghi
A list of one or more lines starting with a colon creates a
description list
without definition terms, and with the items as definition descriptions, hence indented. However, if the colons are in front of the codes "*" or "#" of an unordered or ordered list, the list is treated as one definition description, so the whole list is indented.
ul
ol
li
abc
li
li
def
li
li
ghi
li
ol
ul
abc
def
ghi
MediaWiki translates an unordered list (ul) without any list items (li) into a div with a
style="margin-left: 2em"
, causing indentation of the contents. This is
the most versatile method
, as it allows starting with a number other than 1, see below.
ul
#abc
#def
#ghi
ul
abc
def
ghi
Like above, with the content of the "unordered list without any list items", which itself is an ordered list, expressed with # codes. The HTML produced, and hence the rendering, is the same. This is the
recommended
method when starting the list at 1.
Specifying a starting value
edit
Specifying a starting value is possible with HTML syntax.
ol
start
"9"
li
Amsterdam
li
li
Rotterdam
li
li
The Hague
li
ol
Amsterdam
Rotterdam
The Hague
Or:
ol
li
value
"9"
Amsterdam
li
li
value
"8"
Rotterdam
li
li
value
"7"
The Hague
li
ol
Amsterdam
Rotterdam
The Hague
Comparison with a table
edit
Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax:
{|
|-
| align=right | 9.|| Amsterdam
|-
| align=right | 10.|| Rotterdam
|-
| align=right | 11.|| The Hague
|}
gives:
9.
Amsterdam
10.
Rotterdam
11.
The Hague
This non-automatic numbering has the advantage that if a text refers to the numbers, insertion or deletion of an item does not disturb the correspondence.
Multi-column lists
edit
See also
Template:Col-begin
Template:Col-break
Template:Col-end
Multi-column bulleted list
edit
div
style
"column-count:2"
* apple
* carpet
* geography
* mountain
* nowhere
* postage
* ragged
* toast
div
gives:
apple
carpet
geography
mountain
nowhere
postage
ragged
toast
div
style
"column-count:3"
* apple
* carpet
* geography
* mountain
* nowhere
* postage
* ragged
* toast
div
gives:
apple
carpet
geography
mountain
nowhere
postage
ragged
toast
Multi-column numbered list
edit
div
style
"column-count:3"
# apple
# carpet
# geography
# mountain
# nowhere
# postage
# ragged
# toast
div
gives:
apple
carpet
geography
mountain
nowhere
postage
ragged
toast
Below a starting value is specified, with HTML-syntax (for the first column either wiki-syntax or HTML-syntax can be used).
In combination with the extra indentation explained in the previous section:
{| valign="top"
|-
ul
><
ol
start
"125"
><
li
li
><
li
bb
li
><
li
ccc
li
>ol
>ul
ul
><
ol
start
"128"
><
li
ddd
li
><
li
ee
li
><
li
li
>ol
>ul
|}
gives
bb
ccc
ddd
ee
Using
m:Template:multi-column numbered list
the computation of the starting values can be automated, and only the first starting value and the number of items in each column except the last has to be specified. Adding an item to, or removing an item from a column requires adjusting only one number, the number of items in that column, instead of changing the starting numbers for all subsequent columns.
{{Multi-column numbered list|125|a
li
bb
li
ccc|3|
li
ddd
li
ee
li
f}}
gives:
bb
ccc
ddd
ee
{{Multi-column numbered list|lst=lower-alpha|125|a
li
bb
li
ccc|3|
li
ddd
li
ee|2|
li
f}}
gives:
bb
ccc
ddd
ee
{{Multi-column numbered list|lst=lower-roman|125|a
li
bb
li
ccc|3|
li
ddd
li
ee|2|
li
f}}
gives:
bb
ccc
ddd
ee
{{Multi-column numbered list|lst=disc||a
li
bb
li
ccc||
li
ddd
li
ee||
li
f}}
gives:
bb
ccc
ddd
ee
Streamlined style or horizontal style
edit
It is also possible to present short lists using very basic formatting, such as:
''Title of list:'' example 1, example 2, example 3
Title of list:
example 1, example 2, example 3
This style requires less space on the page, and is preferred if there are only a few entries in the list, it can be read easily, and a direct edit point is not required. The list items should start with a lowercase letter unless they are proper nouns.
Tables
edit
A one-column table is very similar to a list, but it allows sorting. If the wikitext itself is already sorted with the same sortkey, this advantage does not apply.
A multiple-column table allows sorting on any column.
See also
When to use tables
Changing unordered lists to ordered ones
edit
With the CSS
ul
list-style
decimal
unordered lists are changed to ordered ones. This applies (as far as the CSS selector does not restrict this) to all ul-lists in the HTML source code:
those produced with *
those with
‎<
ul
in the wikitext
those produced by the system
Since each special page, like other pages, has a class based on the pagename, one can separately specify for each type whether the lists should be ordered. See also
User contributions
and
What links here
However, it does not seem possible to make all page history lists ordered (unless one makes
all
lists ordered), because the class name is based on the page for which the history is viewed.
See also
edit
Wikipedia help page about lists
Module:Sort definition list
– A
Scribunto
module that allows to sort definition lists by the term defined, useful on multilingual wikis.
Retrieved from "
Categories
List
Help
Help
Lists
Add topic