Help:List
Template:Short description Script error: No such module "For". Script error: No such module "about". Template:Wikipedia how to Template:TOCright This help page explains how to create and format lists on the English Wikipedia.
List basics
There are three types of lists: unordered lists, ordered lists, and description lists (a.k.a. definition lists or association lists). In the following sections, various list types are used for different examples, but other list types will generally give corresponding results. Ordered (numbered) lists should usually be used only for list items that should be in a specific order, such as steps in a cooking recipe.
Script error: No such module "anchor". Template:Markup
Script error: No such module "anchor". Template:Markup
Script error: No such module "anchor". Template:Markup
Common mistakes
There must be no blank lines between list items. Blank lines terminate a list, splitting it into two separate lists. This is most easily illustrated using an ordered list:
Template:MarkupIn the second example above, the numbering resets after the blank line. This problem is less noticeable with other list types, but it still affects the underlying HTML code and may have disruptive effects for some readers; see WP:LISTGAP for details. In order to be a list, each line must begin the same way. This holds true for mixed lists. Template:MarkupThis mistake can also be less noticeable in some circumstances, but it creates single-item lists of different types; besides being semantically wrong, this may cause disruptive side effects for some readers. Do not use a semicolon simply to give a list a title. Semicolons and colons make one kind of list; asterisks make another. Template:Markup
Paragraphs and other breaks
Script error: No such module "anchor". All of the techniques described in this section can be used with each other and with any type of list, at any list level.
Paragraphs inside list items
For simplicity, list items in pure wiki markup cannot be more complex than a basic paragraph. A line break in the wikimarkup of a list item will end not just the item but the entire list, and reset the counter on ordered lists. Separating unordered list items with blank lines may look approximately normal on-screen, but it creates many separate one-item lists, which is a problem for people using screen readers and is discouraged by the guideline on accessibility for people with disabilities, and is also problematic for machine analysis of the article, and for reuse of Wikipedia content more generally.
Paragraphs can be created inside list items by using the HTML Template:Tag (paragraph) element around the second and subsequent paragraphs, Template:Em: Template:Markup
Do not use Template:Tag as a substitute for Template:Tag; they have different semantics and are not interchangeable.
For code readability (the improvement is more apparent when the paragraphs are long, rather than with short examples like these), line-breaks may be created with HTML comments, <!-- ... -->, that begin on one line against the end of that line's code and end on another line, against the beginning of that line's code:
Template:Markup
This technique can be used with the other examples below.
Line breaks inside list items
Use a single Template:Tag for a non-paragraph line break, e.g. where using a nested list is not desired because sub-items are already preceded by numbers:
This must be done with coded Template:Tag line breaks; an actual wikitext linebreak (i.e. pressing Template:Keypress while writing the source code) will bring the list to an end.
Nested blocks inside list items
Similar HTML usage can provide for block quotations within list items: Template:Markup
Another case like this is small nested code blocks: Template:Markup
Here, linebreaks still cannot occur inside the list item, even if they are inside Template:Tag, and the HTML comment trick does not work inside Template:Tag, which is why this technique is only suitable for Template:Em code examples. For longer ones, see [[mw:Extension:SyntaxHighlight|the Template:Tag MediaWiki tag]].
The HTML comment trick does work Template:Em elements inside the same list item: Template:Markup
Continuing a list item after a sub-item
Unlike in HTML, in wikimarkup, unfortunately, sublists follow the same rules as sections of a page. In other words a list item cannot continue on again after sublist has started. Instead, a new item (or new list) must start.
This makes the following type of example impossible using only wikimarkup (whether using numbered or bulleted lists, or a combination):
|
For single lists with multiple subitems / indentation levels, one can either use HTML tags directly, or the Template:Tl and/or Template:Tl templates. The HTML tag for an unordered (bulleted) list is <ul> and for an ordered (numbered) list is <ol>, both enumerate each new list item using the <li> tag. For complex lists, use of the templates is usually recommended.
Attempting to produce a single multilayered list using wikimarkup will instead result in the software attempting to create multiple, nested lists, which generally results in visually confusing formatting and/or breaking list numbering, as well as breaking functionality for users of screen readers for the visually impaired.
For a bulleted list, this limitation can be somewhat worked around by splitting every item into a new list; and using indented text where necessary. However this is still not recommended. With numbered lists this approach will break the numbering.
Template:Markup
The last of these is visually confusing and results in invalid markup. It caused the creation of an embedded but improperly formed description list (the Template:Tag HTML element): it has a definition, indicated by : (in HTML that's Template:Tag), but no term (the missing ; element, which corresponds to HTML Template:Tag).
Similar problems occur with bulleted and mixed bulleted/numbered lists:Template:Markup
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:
Template:Markup
Again, the third example is not desirable, as it produces broken markup and is visually confusing anyway.
Spacing between items
For an ordered list with items that are more than one paragraph long, using the HTML comment trick mentioned above to add a blank line between items Template:Em may be necessary to avoid editor confusion. This is done with a commented-out line:
# First item<!--
-->
# Second item
This doesn't produce unwanted visible spacing or bad list code in the rendered page like adding a plain blank line would:
- First item
- Second item
The comment must begin on the same line on which the preceding item ends, and the comment must end on its own line.
Wrong:
# First item
<!--
-->
# Second item
Wrong:
# First item
<!--
-->#Second item
If the Template:Em has a readability problem due to complex list items, or for some other reason space is desired between list items, simply add a pair of explicit HTML line-breaks to the end of the list items:
# Item 1<br/><br/>
# Item 2<br/><br/>
gives
- Item 1
- Item 2
Compare the version without the spacing:
- Item 1
- Item 2
Changing the list type
The list type (which type of marker appears before the list item) can be changed in CSS by setting the list-style-type property. This can be done using the Template:Tl template:
Or, using HTML: Template:Markup
Extra indentation of lists
In a numbered list in a large font, some browsers do not show more than two digits (2 spaces width) of indentation, unless extra indentation is applied (if there are multiple columns: for each column). This is fixed by increasing the default indentation of 3.2em by 2em more, and it can be done in multiple ways:
When using explicit HTML Template:Tag list items, use an explicit CSS margin spacing of 4em to double the default 2em spacing. Though not the simplest, this is Template:Em, as it does not rely on any peculiarities of the parser, nor on abusing any semantic markup for purely visual purposes. It allows starting with a number other than 1 (see below). It is the recommended method for complex lists.
The parser translates an ordered list, Template:Tag, without any list items, Template:Tag (in this case, it contains just another Template:Tag) into a Template:Tag with a style="margin-left: 2em;", causing indentation of the contents. This is a versatile but potentially confusing method, as it allows starting with a number other than 1 (see below). It is Template:Em. While the parser corrects it on-the-fly, only MediaWiki experts know this, with the result that other editors are likely to try to "correct" it by removing what looks like redundant Template:Tag code.
Template:Markup
Just put an explicit HTML Template:Tag around wiki-markup list items. It functions the same as the previous example with the content of the "ordered 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 simplest method, and recommended when starting a simple list with number 1. Template:Markup
A list of one or more lines starting with a colon creates an HTML5 description list (formerly definition list in HTML4 and association list in draft HTML5), without terms to be defined/described/associated, but with the items as descriptions/definitions/associations, 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 description/definition, so the whole list is indented.
Template:Strongbad: The technique below produces poorly formed (though technically DTD-validating) markup and abuses the semantic HTML purpose of description lists for a purely visual effect, and is thus a usability and accessibility problem. It will work in a hurry, but Template:Em; see WP:Manual of Style/Glossaries for several approaches.
Specifying a starting value
Specifying a starting value is possible with the Template:Tl template by using the start and value attributes.
Or: Template:Markup
Alternatively, only the list item whose value is being set needs to be written in HTML, the rest of the list may use wiki syntax: Template:Markup This does not work inside Template:Tag.
Comparison with a table
Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax:
{|
|-
| style="text-align: right" | 9. || Amsterdam
|-
| style="text-align: right" | 10. || Rotterdam
|-
| style="text-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
Script error: No such module "anchor". Wrap a list in Template:Tl to add columns.
<templatestyles src="Col-begin/styles.css"/>
{{columns-list|colwidth=10em|
* 1
* 2
* 3
* 4
* 5
}}
|
This setup also works with numbered lists.
<templatestyles src="Col-begin/styles.css"/>
{{columns-list|colwidth=10em|
# a
# b
# c
# d
# e
}}
|
Template:Tl is the general solution. You can combine it with any other type of list formatting, including but not limited to every type of list syntax mentioned on this page. It works with content that are not lists as well.
Streamlined style or horizontal style
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.
See also WP:HLIST.
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 Help:Table.
Interaction with floating elements
{{#section-h:Wikipedia:Extended image syntax|Interaction between left-floating images and lists}}
Manipulating lists with user stylesheets
Script error: No such module "labelled list hatnote".
Virtually anything about how lists are displayed can be customized at the user end with CSS. Some of the more useful tweaks are outlined below. Of course, you enter the code in Text Editor mode — if you enter it in WYSIWYG mode, it is entered using escape characters. Also, if you enter HTML in the Text Editor and switch to WYSIWYG mode, the HTML is lost and re-converted to markdown without styles.
Extra indentation
As noted above, in a numbered list in a large font, some browsers do not show more than two digits of indentation width, unless extra indentation is applied (if there are multiple columns; then indentation for each column). While this should be fixed in the wikicode, user stylesheet CSS can work around the problem for as long as it is present, by increasing the default indentation of 3.2em by 2em more:
ol { margin-left: 5.2em;}
Changing unordered lists to ordered ones
With the following user style CSS, ul { list-style: decimal; }, unordered lists are changed to ordered ones for sighted users (but not users who must use assistive technology). 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 Help:User contributions#User styles and Help:What links here#User styles.
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.
How to find entries for a list
The easiest way to find relevant articles for a new list or missing entries in an existing one is by finding the most relevant category and checking its entries. Sometimes lists are about things that are intersections of categories for which the PetScan tool can be used.
More relevant articles may also be found linked in the list's topic's article and the articles already featured in the list − most often in their "See also" sections (if existent) and the automatically suggested "RELATED ARTICLES" below them.
Other ways to find relevant articles include searching Wikipedia for the lists' topic and searching the Web for the topic in quotes " (with synonyms also in quotes and appended after an OR) and appending the word wiki or Wikipedia or site:Wikipedia.org to them.
Lastly the "What links here"-tool can be used on the list's topic's article to find relevant articles.
For lists that do not require the entries to have a Wikipedia article there are additional ways of finding relevant entries such as lists on external websites (e.g. Goodreads for books) − typically involving Web searches.
See also
Script error: No such module "Portal".
- MOS:PLIST, which explains the formatting of unbulleted lists.
- Wikipedia:Manual of Style/Lists, for suggested styles of lists.
- List formatting templates category.
- Template:Tn and Template:Tn, dots (interpuncts) and bullets that can be used to separate items in horizontal lists without the use of HTML list mark-up. A more accessible, manageable and semantically robust method is to use Template:Tl or Template:Tl.
- Wikipedia:Line break handling, including how to handle line wrapping in horizontal lists.
- Wikipedia:Help desk, to ask questions about using lists in articles if you weren't able to find the information you need here.
Template:List navbox Template:Help navigation Template:Wikipedia technical help