--- url: "https://web.dev/learn/css/counters" titulek: "Counters and list styles | web.dev" h1: "Counters and list styles Stay organized with collections Save and categorize content based on your preferences." popis: "CSS provides several ways to control the counters in a list for different use cases. In this module, you'll learn how to control the counters in a list." jazyk: "en" kanonicka: "https://web.dev/learn/css/counters" drobecky: ["web.dev", "Resources", "CSS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 00:04:31" znaku: 4912 slov: 764 kodovani: "iso-8859-2" sha256: "3d3bdf62a2507c370039c56d71f057713454a0f3f5dc09fe2a45e94706bbaae2" --- Counters and list styles Stay organized with collections Save and categorize content based on your preferences. Many types of content are best represented as an HTML [list](/learn/html/lists). For ordered list content, like recipe steps or footnotes for an article, the marker often contains information as well. CSS provides several ways to control the counters in a list. List styles There are a wide range of predefined list style types that support numbers, alphabetical, roman numerals, and many international counting systems. In addition to the styles supported by browsers, W3C published [Ready-made Counter Styles](https://w3c.github.io/predefined-counter-styles), with support for 181 additional styles in 45 writing systems. If these options don't fit your needs, you can also define a custom [`@counter-style`](https://developer.mozilla.org/docs/Web/CSS/@counter-style). This lets you specify custom symbols, a prefix and suffix, and more. By default, the item marker is `outside` the list, positioned in front of the list, and right aligned. You can also position the item marker inside the list, with `list-style-position: inside`. Counters While list styles control how the list item markers are displayed, counters allow you to control the values to be displayed. For `
  • ` list item elements, the browser creates a counter called `list-item` that is incremented by 1 for each list item encountered. CSS counters keep a running count of the number of times an element that has a corresponding `counter-increment` value set is rendered. To create a new counter, use `counter-reset` with a counter name and, optionally, an initial value. You will often set this on a parent element that holds all the elements that will be counted. Then, add a `counter-increment` property on each element you want to count. Finally, display the counter value using the `counter()` function. In this example, we want to display the running count of footnotes as the link text for each footnote. Since we want a single counter for the entire document, we set `counter-reset: note` on the body, and increment on each footnote link. You can also have multiple counters counting different items. In the footnotes example, what if you wanted to display the index of the section and paragraph that the footnote is in? The section count can be created on the body using `counter-reset`, and then increment on each `

    ` element. We want the paragraph count to reset for each section, so we'll use `counter-reset` on `

    ` elements, and increment on `

    ` elements. Finally, we combine the counter values in the `content` property. `a:after { content: "(S" counter(section) "P" counter(paragraph) "N" counter(note) ")"; font-size: small; vertical-align: super; }` Nested counters What happens when you nest a list inside of a list? The `list-item` counter is initialized for each `