CSS - negative

When defining custom counter styles, the negative descriptor lets the author alter the representations of negative counter values, by providing a way to specify symbols to be appended or prepended to the counter representation when the value is negative. If the counter value is negative, the symbol provided as value for the descriptor will be prepended to the counter representation; and a second symbol if specified, will be appended to the representation. The negative descriptor has effect only if the system value is symbolic, alphabetic, numeric, additive, or extends, if the extended counter style itself uses a negative sign. If the negative descriptor is specified for other systems that don't support negative counter values, then the descriptor is ignored.

Example

HTML Content

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

CSS Content

@counter-style neg {
    system: numeric;
    symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
    negative: "(-" ")";
}
.list {
    list-style: neg;
}

Result

Syntax  

/* <symbol> values */
negative: "-";       /* Prepends '-' if value is negative */
negative: "(" ")";   /* Surrounds value by '(' and ')' if it is negative */

Values

First <symbol>
This symbol will be prepended to the representation when the counter is negative.
Second <symbol>
If present, this symbol will be appended to the representation when the counter is negative.

Formal syntax

<symbol> <symbol>?

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

Description  

When defining custom counter styles, the negative descriptor lets the author alter the representations of negative counter values, by providing a way to specify symbols to be appended or prepended to the counter representation when the value is negative. If the counter value is negative, the symbol provided as value for the descriptor will be prepended to the counter representation; and a second symbol if specified, will be appended to the representation. The negative descriptor has effect only if the system value is symbolic, alphabetic, numeric, additive, or extends, if the extended counter style itself uses a negative sign. If the negative descriptor is specified for other systems that don't support negative counter values, then the descriptor is ignored.

Related at-rule@counter-style
Initial value"-" hyphen-minus
Mediaall
Computed valueas specified
Canonical orderorder of appearance in the formal grammar of the values

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  

Specifications  

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

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/@counter-style/negative