Main Page
Welcome To The North Modding Company Bergsbruk Wiki Page
Consult the User's Guide for information on using the wiki software.
<languages/> Template:PD Help Page
<translate> This page deals with creating lists in MediaWiki.
List basics
<tvar name=mw>
- REDIRECT Template:Localized link</tvar> offers three types of lists: ordered lists, unordered lists, and description or definition lists. In the following sections, ordered lists are used for examples. Unordered lists would give corresponding results.
</translate>
<translate> Wikitext</translate> | <translate> Rendering</translate> |
---|---|
<translate> <!--T:6--> * Lists are easy to do: ** start every line * with a star ** more stars mean *** deeper levels</translate> |
<translate>
|
<translate> <!--T:8--> * A newline * in a list marks the end of the list. Of course * you can * start again.</translate> |
<translate>
marks the end of the list. Of course
|
<translate> <!--T:10--> # Numbered lists are good ## very organized ## easy to follow</translate> |
<translate>
|
<translate> <!--T:12--> * You can also ** break lines ** like this</translate> |
<translate>
|
<translate> <!--T:14--> ; Description or definition lists ; item : definition ; semicolon plus term : colon plus definition</translate> |
<translate>
|
<translate> <!--T:16--> ; 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</translate> |
<translate>
|
<translate> <!--T:18--> * Or create mixed lists *# and nest them *#* like this *#*; definitions *#*: work: *#*; apple *#*; banana *#*: fruits</translate> |
<translate>
|
<translate>
Paragraphs in lists
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. Two line break symbols, <tvar name=brtags><source lang=html inline>
</source></tvar>, will create the desired effect. So will enclosing all but the first paragraph with <tvar name=ptag>Template:Tag</tvar>.
Continuing a list item after a sub-item
In HTML, a list item may contain several sublists, not necessarily adjacent; thus there may be parts of the list item not only before the first sublist, but also between sublists, and after the last one. However, in wiki-syntax, sublists follow the same rules as sections of a page: the only possible part of the list item not in sublists is before the first sublist.
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 may give, depending on CSS, a blank line before and after each list, in which case, for uniformity, every first-level list item could be made a separate list.
Numbered lists illustrate that what should look like one list may, for the software, consist of multiple lists; unnumbered lists give a corresponding result, except that the problem of restarting with 1 is not applicable. </translate>
<source lang=html>
|
|
vs. | |
<translate> <!--T:38--> #list item A1 ##list item B1 ##list item B2 #:continuing list item A1 #list item A2</translate> |
<translate>
|
<translate> 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: </translate>
<translate> <!--T:41--> #list item A1 ##list item B1 ###list item C1 ##:continuing list item B1 ##list item B2 #list item A2 </translate>
<translate> gives
- list item A1
- list item B1
- list item C1
- continuing list item B1
- list item B2
- list item B1
- list item A2
See also <tvar name=1>Template:Tim</tvar>. </translate>
It is possible to embed unnumbered bullets inside enclosing numbered items:
# list item A #* nested bullet A1 #* nested bullet A2 # continuing list item B #* nested bullet B1 #* nested bullet B2
gives
- list item A
- nested bullet A1
- nested bullet A2
- continuing list item B
- nested bullet B1
- nested bullet B2
<translate>
Changing the list type
Per list
The list type (which type of marker appears before the list item) can be changed in CSS by setting the <tvar name=list-style-type>list-style-type</tvar> property: </translate>
<translate> Wikitext</translate> | <translate> Rendering</translate> |
---|---|
<source lang=html>
|
|
<source lang=html>
|
|
Site-wide
The standard #, ##, ### wikitext can be used alongisde CSS in MediaWiki:Common.css to produce the usual system of numbered lists (1, 2, 3; then a, b, c; then i, ii, iii):
<syntaxhighlight lang="css"> ol { list-style-type: decimal; } ol li > ol { list-style-type: lower-alpha; } ol li > ol li > ol { list-style-type: lower-roman; } </syntaxhighlight>
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 |
|
<translate>
Extra indentation of lists
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 columns: for each column). This can be done with CSS:</translate>
ol { margin-left: 2cm}
<translate> or alternatively, like below. </translate>
<translate> Wikitext</translate> | <translate> Rendering</translate> | <translate> Comments</translate> |
---|---|---|
:#abc :#def :#ghi |
|
<translate> A list of one or more lines starting with a colon creates a [<tvar name=link1>http://www.w3.org/TR/html4/struct/lists.html#edef-DL</tvar> 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.</translate> |
<source lang=html>
</source> |
|
<translate> MediaWiki translates an unordered list (ul) without any list items (li) into a div with a <tvar name=margin-left>style="margin-left: 2em" </tvar>, causing indentation of the contents. This is the most versatile method, as it allows starting with a number other than 1, see below.</translate>
|
<source lang=html>
</source> |
|
<translate> 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.</translate> |
<translate> To demonstrate that all three methods show all digits of 3-digit numbers, see [[<tvar name=metalink1>m:Help:List demo</tvar>|List demo]].
Specifying a starting value
Specifying a starting value is possible with HTML syntax. </translate>
<source lang=html>
</source> |
|
<translate> Or:</translate>
<source lang=html>
</source> |
|
<translate>
Comparison with a table
Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax: </translate>
{| |- | align=right | 9.|| <translate><!--T:87--> Amsterdam</translate> |- | align=right | 10.|| <translate><!--T:88--> Rotterdam</translate> |- | align=right | 11.|| <translate><!--T:89--> The Hague</translate> |}
<translate> gives:</translate>
9. | <translate> Amsterdam</translate> |
10. | <translate> Rotterdam</translate> |
11. | <translate> The Hague</translate> |
<translate> 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
See also <tvar name=coltemplates>Template:Col-begin, Template:Col-break, Template:Col-end</tvar>.
Multi-column bulleted list
</translate>
<source lang=html>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
</source>
<translate> gives:</translate>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
<source lang=html>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
</source>
<translate> gives:</translate>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
<translate>
Multi-column numbered list
</translate>
<source lang=html>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
</source>
<translate> gives:</translate>
<translate>
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
</translate>
<translate> 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: </translate>
<source lang=html>
|
|
</source>
<translate> gives</translate>
|
|
<translate> Using <tvar name=templatelink1>Template:Tim</tvar> 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. </translate>
<source lang=html> Template:Multi-column numbered list </source>
<translate> gives:</translate>
Template:Multi-column numbered list
<source lang=html> Template:Multi-column numbered list </source>
<translate> gives:</translate>
Template:Multi-column numbered list
<source lang=html> Template:Multi-column numbered list </source>
<translate> gives:</translate>
Template:Multi-column numbered list
<source lang=html> Template:Multi-column numbered list </source>
<translate> gives:</translate>
Template:Multi-column numbered list
<translate>
Streamlined style or horizontal style
It is also possible to present short lists using very basic formatting, such as: </translate>
<translate><!--T:117--> ''Title of list:'' example 1, example 2, example 3</translate>
<translate> Title of list: example 1, example 2, example 3</translate>
<translate> 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
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 [[<tvar name=wikipedialink1>:en:Wikipedia:When to use tables</tvar>|When to use tables]].
Changing unordered lists to ordered ones
With the CSS</translate>
ul { list-style: decimal }
<translate> 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 <tvar name=ul>Template:Tag</tvar> 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 [[<tvar name=link1>Help:User contributions#User styles</tvar>|User contributions]] and [[<tvar name=link2>Help:What links here#User styles</tvar>|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
</translate>
- Module:Sort definition list - <translate> A Scribunto module that allows to sort definition lists by the term defined, useful on multilingual wikis. </translate>
[[Category:List{{#translation:}}]] [[Category:Help{{#translation:}}]]