Jump to content

Help talk:Lists

Add topic
From mediawiki.org
Latest comment: 11 months ago by JWBTH in topic Document a numbered list hack?

Zero-indexed ordered lists?

[edit]

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


How would one do

0.

1.

2.

? And can that be made default on a wiki? Arlo Barnes (talk) 04:01, 19 July 2017 (UTC)Reply

<ol start="0">
<li></li>
<li></li>
<li></li>
</ol> Prostologin 1 (talk) 16:38, 19 July 2017 (UTC)Reply
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

How to write sub-numbered lists

[edit]
1. Fruits
 1.1. Banana
 1.2. Apple
 1.3. Orange
2. Vehicles
 2.1. Car
 2.2. Motorcycle Actiuinformatica (talk) 08:03, 1 March 2019 (UTC)Reply

This is an old question, but I have a suggestion on how you could implement what you have referred to as sub-numbered ordered lists.

If you can edit the wiki's .css you can achieve sub-numbered ordered lists by creating a style declaration for such lists, and then wrapping the ordered list wiki-markup in a div with the specified class. See contents of the table below.

The final example will not display properly until after you have made appropriate edits to the wiki's .css via, for example, the edit options available here: Your preferences: 'Appearance' section, under the Skin heading.

Of course, changes to your personal .css will only be reflected when you are logged in with the account of the person under which the changes were made. You would need greater access permissions to edit the site-wide .css in your site's Mediawiki:Commons.css file for everyone to be able to see the resulting sub-numbered lists.

css
.style-for-sub-numbered-lists ol {
  counter-reset: item
}
.style-for-sub-numbered-lists li {
  display: block
}
.style-for-sub-numbered-lists li:before {
  content: counters(item, ".") ". ";
  counter-increment: item;
}

wiki-markup
<div class="style-for-sub-numbered-lists">
# Fruits
## Banana
## Apple
## Orange
# Vehicles
## Car
## Motorcycle
</div>

Simulated rendering of wiki-markup.
   1. Fruits
        1.1. Banana
        1.2. Apple
        1.3. Orange
   2. Vehicles
        2.1. Car
        2.2. Motorcycle
Actual rendering of wiki-markup if you have edited the .css, for example through the links for changing your personal .css here: Your preferences: 'Appearance' section, under the Skin heading. If the css has not been changed, then the rendering will look like the classic mediawiki ordered list rendering, that is, with no sub-numbering.
  1. Fruits
    1. Banana
    2. Apple
    3. Orange
  2. Vehicles
    1. Car
    2. Motorcycle

Thanks to https://stackoverflow.com/a/10405962 'Html ordered list 1.1, 1.2 (Nested counters and scope) not working' Dennis J au (talk) 08:32, 22 November 2021 (UTC)Reply

[edit]

MediaWiki:Common.css is a suppressed page; what to use instead ?

2 mars 2017 à 02:55 😂 discussion contributions a supprimé la page MediaWiki:Common.css (Meh, didn't work)   (remercier)

Christian 🇫🇷 FR (talk) 08:44, 17 September 2022 (UTC)Reply

MediaWiki:Common.css does not exist locally, but it has default content:
/* CSS placed here will be applied to all skins */
Shirayuki (talk) 10:17, 17 September 2022 (UTC)Reply

Document a numbered list hack?

[edit]

How do we feel about documenting this hack? It could be a lot simpler for the user's perspective:

# <li value=5>test
# test
# test
# test
  1. test
  2. test
  3. test
  4. test

This results in this HTML:

<ol><li class="mw-empty-elt"></li><li value="5">test</li>
<li>test</li>
<li>test</li>
<li>test</li></ol>

Note the empty ‎<li>...‎</li> element. It doesn't seem to affect anything meaningfully. It has display: none; from the class, so screen readers ignore it. JWBTH (talk) 04:34, 19 September 2025 (UTC)Reply