pad

Summary

The pad descriptor can be used with custom counter style definitions when you need the marker representations to have a minimum length. 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 value0 ""
Mediaall
Computed valueas specified
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

pad: 3 "0";

Values

<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>.

Formal syntax

<integer> && <symbol>

where
<symbol> = <string> | <image> | <ident>

Example

HTML Content

<ul class="list">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
    <li>Five</li>
</ul>

CSS Content

@counter-style pad-example {
    system: numeric;
    symbols: "0" "1" "2" "3" "4" "5";
    pad: 2 "0";
}
.list {
    list-style: pad-example;
}

Result

Specifications

Specification Status Comment
CSS Counter Styles Level 3
The definition of 'pad' in that specification.
Candidate Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support 33 (33) No support No support No support
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support 33 (33) No support No support No support

See also

Document Tags and Contributors

 Contributors to this page: duncanmcdonald, teoli, Sebastianz, kscarfone, jsx
 Last updated by: duncanmcdonald,