The pad
descriptor can be used with custom counter style definitions when you need the marker representations to have a minimum length.
The pad
descriptor can be used with custom counter style definitions when you need the marker representations to have a minimum length.
pad: 3 "0";
<integer> && <symbol>
The <integer>
specifies a minimum length that all counter representations must reach. The value must be non-negative. If the minimum length is not reached, the representation will be padded with the specified <symbol>
.
If a marker representation is smaller than the specified pad length, then the marker will be padded with the specified pad symbol. Marker representations longer than the pad length are constructed as normal. Pad descriptor takes the minimum marker length as an integer and a symbol to be used for padding as the second parameter. A common usage of the pad descriptor is when you need your list to start numbering from 01 and go through 02, 03 and so on, instead of just 1, 2, 3…
Related at-rule | @counter-style |
---|---|
Initial value | 0 "" |
Computed value | as specified |
pad =
<integer [0,∞]> &&
<symbol>
<symbol> =
<string> |
<image> |
<custom-ident>
<image> =
<url> |
<gradient>
<url> =
url( <string> <url-modifier>* ) |
src( <string> <url-modifier>* )
<ul class="list"> <li>One</li> <li>Two</li> <li>Three</li> <li>Four</li> <li>Five</li> </ul>
@counter-style pad-example { system: numeric; symbols: "0" "1" "2" "3" "4" "5"; pad: 2 "0"; } .list { list-style: pad-example; }
Specification |
---|
CSS Counter Styles Level 3 # counter-style-pad |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
pad |
91 | 91 | 33 | No | 77 | No | 91 | 91 | 33 | 64 | No | 16.0 |
list-style
, list-style-image
, list-style-position
symbols()
, the functional notation creating anonymous counter styles.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style/pad