W3C

CSS Counter Styles Level 3

W3C Working Draft

This version:
http://www.w3.org/TR/2013/WD-css-counter-styles-3-20130221/
Latest version:
http://www.w3.org/TR/css-counter-styles-3/
Editor's Draft:
http://dev.w3.org/csswg/css-counter-styles-3/
Previous version:
http://www.w3.org/TR/2012/WD-css-counter-styles-3-20121009/
Issue Tracking:
Bugzilla
Feedback:
www-style@w3.org with subject line “[css-counter-styles] … message topic …
Editor:
Tab Atkins Jr., Google, Inc.

Abstract

This module introduces the ‘@counter-style’ rule, which allows authors to define their own custom counter styles for use with CSS list-marker and generated-content counters [CSS3LIST]. It also predefines a set of common counter styles, including the ones present in CSS2 and CSS2.1. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-counter-styles” in the subject, preferably like this: “[css-counter-styles] …summary of comment…

This document was produced by the CSS Working Group (part of the Style Activity).

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

The following counter styles are at-risk: ‘cjk-decimal’, ‘hebrew’, ‘hiragana’, ‘hiragana-iroha’, ‘katakana’, ‘katakana-iroha’, ‘japanese-informal’, ‘japanese-formal’, ‘korean-hangul-formal’, ‘korean-hanja-informal’, ‘korean-hanja-formal’, ‘simp-chinese-informal’, ‘simp-chinese-formal’, ‘trad-chinese-informal’, ‘trad-chinese-formal’, and ‘ethiopic-numeric’.

Table of contents


1. Introduction

CSS 1 defined a handful of useful counter styles based on the styles that HTML traditionally allowed on ordered and unordered lists. While this was expanded slightly by CSS2.1, it doesn't address the needs of worldwide typography.

This module introduces the ‘@counter-style’ rule which allows CSS to address this in an open-ended manner, by allowing the author to define their own counter styles. These styles can then be used in the ‘list-style-type’ property or in the counter() and counters() functions. It also defines some additional predefined counter styles, particularly ones which are common but complicated to represent with ‘@counter-style’.

2. Counter Styles

A counter style defines how to convert a counter value into a string. Counter styles are composed of:

When asked to generate a counter representation using a particular counter style for a particular counter value, follow these steps:

  1. If the counter value is outside the range of the counter style, exit this algorithm and instead generate a counter representation using the counter style's fallback style and the same counter value.
  2. Using the counter value and the counter algorithm for the counter style, generate an initial representation for the counter value. If the counter value is negative and the counter style is negative-capable, instead generate an initial representation using the absolute value of the counter value.
  3. If the representation uses less symbols than specified in the counter style's ‘width’ descriptor, prepend symbols to the representation as specified in the ‘width’ descriptor.
  4. If the counter value is negative and the counter style is negative-capable, wrap the representation in the counter style's negative sign as specified in the ‘negative’ descriptor.
  5. Return the representation.

Note that the prefix and suffix don't play a part in this algorithm. This is intentional; the prefix and suffix aren't part of the string returned by the counter() or counters() functions. Instead, the prefix and suffix are added by the algorithm that constructs the value of the ‘contents’ property for the ‘::marker’ pseudo-element. This also implies that the prefix and suffix always come from the specified counter-style, even if the actual representation is constructed by a fallback style.

3. Defining Custom Counter Styles: the ‘@counter-style’ rule

The @counter-style rule allows authors to define a custom counter style. The components of a counter style are specified by descriptors in the ‘@counter-style’ rule. The algorithm is specified implicitly by a combination of the ‘system’, ‘symbols’, and ‘additive-symbols’ properties.

The general form of an ‘@counter-style’ rule is:

@counter-style <counter-style-name> {
	[ descriptor: value; ]+
}
	

The <counter-style-name> must be be a valid identifier and must not be ‘decimal’ or ‘none’, or else the rule is invalid. (Note, however, that some names, like ‘inside’ or ‘initial’, might conflict with the existing values of properties like ‘list-style’, and thus won't be usable there.)

Counter style names are case-sensitive. However, the names defined in this specification are ASCII lower-cased on parse wherever they are used as counter styles, e.g. in the ‘list-style’ set of properties, in the ‘@counter-style’ rule, and in the ‘counter()’ functions.

Each ‘@counter-style’ rule specifies a value for every counter-style descriptor, either implicitly or explicitly. Those not given explicit value in the rule take the initial value listed with each descriptor in this specification. These descriptors apply solely within the context of the ‘@counter-style’ rule in which they are defined, and do not apply to document language elements. There is no notion of which elements the descriptors apply to or whether the values are inherited by child elements. When a given descriptor occurs multiple times in a given ‘@counter-style’ rule, only the last specified value is used; all prior values for that descriptor must be ignored.

Defining a ‘@counter-style’ makes it available to the entire document in which it is included. If multiple ‘@counter-style’ rules are defined with the same name, only one wins, according to standard cascade rules. ‘@counter-style’ rules cascade "atomically": if one replaces another of the same name, it replaces it entirely, rather than just replacing the specific descriptors it specifies.

This at-rule conforms with the forward-compatible parsing requirement of CSS; conformant parsers that don't understand these rules will ignore them without error. Any descriptors that are not recognized or implemented by a given user agent must be ignored in their entirety; they do not make the ‘@counter-style’ rule invalid.

3.1. Counter algorithms: the ‘system’ descriptor

Name: system
Value: cyclic | numeric | alphabetic | symbolic | additive | [fixed <integer>?] | [ override <counter-style-name> ]
Initial: symbolic

The ‘system’ descriptor specifies which algorithm will be used to construct the counter's representation based on the counter value. For example, ‘cyclic’ counter styles just cycle through their symbols repeatedly, while ‘numeric’ counter styles interpret their symbols as digits and build their representation accordingly. The systems are defined as follows:

3.1.1. Cycling Symbols: the ‘cyclic’ system

The cyclic counter system cycles repeatedly through its provided symbols, looping back to the beginning when it reaches the end of the list. It can be used for simple bullets (just provide a single counter symbol), or for cycling through multiple symbols. The first counter symbol is used as the representation of the value 1, the second counter symbol (if it exists) is used as the representation of the value 2, etc.

If the system is ‘cyclic’, the ‘symbols’ descriptor must contain at least one counter symbol, or else the ‘@counter-style’ rule is invalid. This system is defined over all counter values.

A "triangle bullet" counter style can be defined as:

@counter-style triangle {
	system: cyclic;
	symbols: ‣;
	suffix: '';
}
		

It will then produce lists that look like:

‣  One
‣  Two
‣  Three
		

If there are N counter symbols and a representation is being constructed for the integer value, the representation is the counter symbol at index ( (value-1) mod N) of the list of counter symbols (0-indexed).

3.1.2. Exhaustible Symbols: the ‘fixed’ system

The fixed counter system runs through its list of counter symbols once, then falls back. It is useful for representing counter styles that only have a finite number of representations. For example, Unicode defines several limited-length runs of special characters meant for lists, such as circled digits.

If the system is ‘fixed’, the ‘symbols’ descriptor must contain at least one counter symbol, or else the ‘@counter-style’ rule is invalid. This system is defined over counter values in a finite range, starting with the first symbol value and having a length equal to the length of the list of counter symbols.

When this system is specified, it may optionally have an integer provided after it, which sets the first symbol value. If it is omitted, the first symbol value is 1.

A "box-corner" counter style can be defined as:

@counter-style box-corner {
	system: fixed;
	symbols: ◰ ◳ ◲ ◱;
	suffix: ':';
}
		

It will then produce lists that look like:

◰:  One
◳:  Two
◲:  Three
◱:  Four
5:  Five
6:  Six
		

The first counter symbol is the representation for the first symbol value, and subsequent counter values are represented by subsequent counter symbols. Once the list of counter symbols is exhausted, further values cannot be represented by this counter style, and must instead be represented by the fallback counter style.

3.1.3. Repeating Symbols: the ‘symbolic’ system

The ‘symbolic’ counter system cycles repeatedly through its provided symbols, doubling, tripling, etc. the symbols on each successive pass through the list. For example, if the original symbols were "*" and "†", then on the second pass they would instead be "**" and "††", while on the third they would be "***"and "†††", etc. It can be used for footnote-style markers, and is also sometimes used for alphabetic-style lists for a slightly different presentation than what the ‘alphabetic’ system presents.

If the system is symbolic, the ‘symbols’ descriptor must contain at least one counter symbol, or else the ‘@counter-style’ rule is invalid. This system is defined only over strictly positive counter values.

An "footnote" counter style can be defined as:

@counter-style footnote {
	system: symbolic;
	symbols: '*' ⁑ † ‡;
	suffix: '';
}
		

It will then produce lists that look like:

*   One
⁑   Two
†   Three
‡   Four
**  Five
⁑⁑  Six
		

Some style guides mandate a list numbering that looks similar to ‘upper-alpha’, but repeats differently after the first 26 values, instead going "AA", "BB", "CC", etc. This can be achieved with the symbolic system:

@counter-style upper-alpha-legal {
	system: symbolic;
	symbols: A B C D E F G H I J K L M 
	         N O P Q R S T U V W X Y Z;
}

This style is identical to ‘upper-alpha’ through the first 27 values, but they diverge after that, with ‘upper-alpha’ going "AB", "AC", "AD", etc. Starting at the 53rd value, ‘upper-alpha’ goes "BA", "BB", "BC", etc., while this style jumps into triple digits with "AAA", "BBB", "CCC", etc.

To construct the representation, run the following algorithm:

Let N be the length of the list of counter symbols, value initially be the counter value, S initially be the empty string, and symbol(n) be the nth counter symbol in the list of counter symbols (0-indexed).

  1. Let the chosen symbol be symbol(value mod N).
  2. Let the representation length be floor( (value - 1) / N ).
  3. Append the chosen symbol to S a number of times equal to the representation length.

Finally, return S.

The ‘symbolic’ system will produce representations with sizes that are linear in the magnitude of the counter value. This can potentially be abused to generate excessively large representations and consume undue amounts of the user's memory or even hang their browser. User agents must support representations at least 20 characters long, but they may choose to instead use the fallback style for representations that would be longer than 20 characters.

3.1.4. Bijective Numerals: the ‘alphabetic’ system

The ‘alphabetic’ counter system interprets the list of counter symbols as digits to an alphabetic numbering system, similar to the default ‘lower-alpha’ counter style, which wraps from ‘a’, ‘b’, ‘c’, to ‘aa’, ‘ab’, ‘ac’. Alphabetic numbering systems do not contain a digit representing 0; so the first value when a new digit is added is composed solely of the first digit. Alphabetic numbering systems are commonly used for lists, and also appear in many spreadsheet programs to number columns. The first counter symbol in the list is interpreted as the digit 1, the second as the digit 2, and so on.

If the system is alphabetic, the ‘symbols’ descriptor must contain at least two counter symbols, or else the ‘@counter-style’ rule is invalid. This system is defined only over strictly positive counter values.

A counter style using go stones can be defined as:

@counter-style go {
	system: alphabetic;
	symbols: url(white.svg) url(black.svg);
	suffix: '';
}
		

It will then produce lists that look like:

One
Two
Three
Four
Five
Six
Seven

This example requires support for SVG images to display correctly.

If there are N counter symbols, the representation is a base N alphabetic number using the counter symbols as digits. To construct the representation, run the following algorithm:

Let N be the length of the list of counter symbols, value initially be the counter value, S initially be the empty string, and symbol(n) be the nth counter symbol in the list of counter symbols (0-indexed).

While value is not equal to 0:

  1. Set value to value - 1.
  2. Prepend symbol( value mod N ) to S.
  3. Set value to floor( value / N ).

Finally, return S.

3.1.5. Positional Numerals: the ‘numeric’ system

The numeric counter system interprets the list of counter symbols as digits to a "place-value" numbering system, similar to the default ‘decimal’ counter style. The first counter symbol in the list is interpreted as the digit 0, the second as the digit 1, and so on.

If the system is ‘numeric’, the ‘symbols’ descriptor must contain at least two counter symbols, or else the ‘@counter-style’ rule is invalid. This system is defined over all counter values.

A "trinary" counter style can be defined as:

@counter-style trinary {
	system: numeric;
	symbols: '0' '1' '2';
}
		

It will then produce lists that look like:

1.   One
2.   Two
10.  Three
11.  Four
12.  Five
20.  Six
		

If there are N counter symbols, the representation is a base N number using the counter symbols as digits. To construct the representation, run the following algorithm:

Let N be the length of the list of counter symbols, value initially be the counter value, S initially be the empty string, and symbol(n) be the nth counter symbol in the list of counter symbols (0-indexed).

  1. If value is 0, append symbol(0) to S and return S.
  2. While value is not equal to 0:
    1. Prepend symbol( value mod N ) to S.
    2. Set value to floor( value / N ).
  3. Return S.

3.1.6. Accumulating Numerals: the ‘additive’ system

The additive counter system is used to represent "sign-value" numbering systems, which, rather than using reusing digits in different positions to change their value, define additional digits with much larger values, so that the value of the number can be obtained by adding all the digits together. This is used in Roman numerals and other numbering systems around the world.

If the system is ‘additive’, the ‘additive-symbols’ descriptor must contain at least one additive tuple, or else the ‘@counter-style’ rule is invalid. This system is nominally defined over all counter values (see algorithm, below, for exact details).

A "dice" counter style can be defined as:

@counter-style dice {
	system: additive;
	additive-symbols: 6 ⚅, 5 ⚄, 4 ⚃, 3 ⚂, 2 ⚁, 1 ⚀;
	suffix: '';
}
		

It will then produce lists that look like:

⚀    One
⚁    Two
⚂    Three
...
⚅⚄   Eleven
⚅⚅   Twelve
⚅⚅⚀  Thirteen
		

To construct the representation, run this algorithm:

Let value initially be the counter value, S initially be the empty string, and symbol list initially be the list of additive tuples.

  1. If value is initially 0, and there is an additive tuple with a weight of 0, append that tuple's counter symbol to S and return S.
  2. While value is greater than 0 and there are elements left in the symbol list:
    1. Pop the first additive tuple from the symbol list. This is the current tuple.
    2. Append the current tuple's counter symbol to S floor( value / current tuple's weight ) times (this may be 0).
    3. Decrement value by the current tuple's weight multiplied by the number of times the current tuple was appended to S in the previous step.
  3. If the loop ended because value is 0, return S. Otherwise, the given counter value cannot be represented by this counter style, and must instead be represented by the fallback counter style.

The ‘additive’ system will produce representations with sizes that are linear in the magnitude of the counter value. This can potentially be abused to generate excessively large representations and consume undue amounts of the user's memory or even hang their browser. User agents must support representations at least 20 characters long, but they may choose to instead use the fallback style for representations that would be longer than 20 characters.

3.1.7. Tweaking Existing Counter Styles: the ‘override’ system

The override system allows an author to use the algorithm of another counter style, but alter other aspects, such as the negative sign or the suffix. If a counter style uses the ‘override’ system, any unspecified descriptors must be taken from the overridden counter style specified, rather than taking their initial values.

If a @counter-style uses the ‘override' system, it must not contain a 'symbols' or 'additive-symbols' descriptor, or else the ’@counter-style'‘ rule is invalid. If the specified counter style name isn’t the name of any currently-defined counter style, it must be treated as if it was overriding the ‘decimal’ counter style.

3.2. Formatting negative values: the ‘negative’ descriptor

Name: negative
Value: <symbol> <symbol>?
Initial: "\2D" ("-" hyphen-minus)

The ‘negative’ descriptor defines how to alter the representation when the counter value is negative.

The first <symbol> in the value is prepended to the representation when the counter value is negative. The second <symbol>, if specified, is appended to the representation when the counter value is negative.

For example, specifying ‘negative: "(" ")";’ will make negative values be wrapped in parentheses, which is sometimes used in financial contexts, like "(2) (1) 0 1 2 3...".

Not all ‘system’ values use a negative sign. In particular, a counter style is negative-capable is one where its ‘system’ value is ‘symbolic’, ‘alphabetic’, ‘numeric’, ‘additive’, or ‘override’ if the overridden counter style is itself negative-capable. If a counter style is not negative-capable, it ignores the negative sign when generating a counter representation.

3.3. Symbols before the marker: the ‘prefix’ descriptor

Name: prefix
Value: <symbol>
Initial: "" (the empty string)

The ‘prefix’ descripter specifies a <symbol> that is prepended to the marker representation. Prefixes are only added by the algorithm for constructing the default contents of the ‘::marker’ pseudo-element; the prefix is not added automatically when the counter() or counters() functions are used. Prefixes come before any negative sign.

3.4. Symbols after the marker: the ‘suffix’ descriptor

Name: suffix
Value: <symbol>
Initial: "\2E" ("." full stop)

The ‘suffix’ descripter specifies a <symbol> that is appended to the marker representation. Suffixes are only added by the algorithm for constructing the default contents of the ‘::marker’ pseudo-element; the suffix is not added automatically when the counter() or counters() functions are used. Suffixes are added to the representation after negative signs.

3.5. Limiting the counter scope: the ‘range’ descriptor

Name: range
Value: [ [ <integer> | infinite ]{2} ]# | auto
Initial: auto

The ‘range’ descriptor defines the ranges over which the counter style is defined. If a counter style is used to represent a counter value outside of its ranges, the counter style instead drops down to its fallback counter style.

auto
The range depends on the counter system. For ‘cyclic’, ‘numeric’, and ‘fixed’ systems, the range is negative infinity to positive infinity. For ‘alphabetic’ and ‘symbolic’ systems, the range is 1 to positive infinity. For ‘additive’ systems, the range is 0 to positive infinity. For ‘override’ systems, the range is identical to the overridden system.
[ [ <integer> | infinite ]{2} ]#
This defines a comma-separated list of ranges. For each individual range, the first value is the lower bound and the second value is the upper bound. This range is inclusive - it contains both the lower and upper bound numbers. If ‘infinite’ is used as the first value in a range, it represents negative infinity; if used as the second value, it represents positive infinity. The range of the counter style is the union of all the ranges defined in the list.

If the lower bound of any range is higher than the upper bound, the entire descriptor is invalid and must be ignored.

Implementations must support ranges with a lower bound of at least -215 and an upper bound of at least 215-1 (the range of a signed 2-byte int). They may support higher ranges. If any specified bound is outside of the implementation's supported bounds, it must be treated as the closest bound that the implementation does support.

3.6. Zero-Padding and Constant-Width Representations: the ‘width’ descriptor

Name: width
Value: <integer> && <symbol>
Initial: 0 ""

The ‘width’ descriptor allows an author to specify a "fixed-width" counter style, where representations shorter than the width are padded with a particular character. Representations larger than the specified width are constructed as normal.

auto
This descriptor has no effect on counter representations.
<integer> && <symbol>
The <integer> specifies a minimum width that all counter representations must reach. If a counter representation would be generated using less <symbol>s than the specified <integer> (before adding prefixes/suffixes/negatives), prepend copies of the specified <symbol> to the representation until the number of symbols reaches the specified width.

If the counter value is negative and the counter style is negative-capable, reduce the width by one or two when determining how many copies to prepend, depending on whether the ‘negative’ descriptor's value is one or two <symbol>s.

The most common example of "fixed-width" numbering is zero-padded decimal numbering. If an author knows that the numbers used will be less than a thousand, for example, it can be zero-padded with a simple ‘width: 3 "0";’ descriptor, ensuring that all of the representations are 3 digits wide.

This will cause, for example, 1 to be represented as "001", 20 to be represented as "020", 300 to be represented as "300", and -4 to be represented as "-04".

3.7. Defining fallback: the ‘fallback’ descriptor

Name: fallback
Value: <counter-style-name>
Initial: decimal

The ‘fallback’ descriptor specifies a fallback counter style to be used when the current counter style can't create a representation for a given counter value. For example, if a counter style defined with a range of 1-10 is asked to represent a counter value of 11, the counter value's representation is instead constructed with the fallback counter style (or possibly the fallback style's fallback style, if the fallback style can't represent that value, etc.).

If the value of the ‘fallback’ descriptor isn't the name of any currently-defined counter style, the used value of the ‘fallback’ descriptor is decimal instead. Similarly, while following fallbacks to find a counter style that can render the given counter value, if a loop in the specified fallbacks is detected, the decimal style must be used instead.

Note that it is not necessarily an error to specify fallback loops. For example, if an author desires a counter style with significantly different representations for even and odd counter values, they may find it easiest to define one style that can only represent odd values and one that can only represent even values, and specify each as the fallback for the other one. Though the fallback graph is circular, at no point do you encounter a loop while following these fallbacks - every counter value is represented by one or the other counter style.

3.8. Marker characters: the ‘symbols’ and ‘additive-symbols’ descriptors

Name: symbols
Value: <symbol>+
Initial: N/A
Name: additive-symbols
Value: [ <integer> && <symbol> ]#
Initial: N/A
<symbol> = <string> | <image> | <identifier>

The ‘symbols’ and ‘additive-symbols’ descriptors specify the symbols used by the marker-construction algorithm specified by the ‘system’ descriptor. The ‘symbols’ descriptor must be specified if the counter system is ‘cyclic’, ‘numeric’, ‘alphabetic’, ‘symbolic’, or ‘fixed’, and the ‘additive-symbols’ descriptor must be specified if the counter system is ‘additive’; otherwise, the ‘@counter-style’ is invalid and must be ignored.

Some counter systems specify that the ‘symbols’ descriptor must have at least two entries. If the counter style's system is such, and the ‘symbols’ descriptor has only a single entry, the counter style is invalid and must be ignored.

Each entry in the ‘symbols’ descriptor's value defines a counter symbol, which is interpreted differently based on the counter style's system. Each entry in the ‘additive-symbols’ descriptor's value defines an additive tuple, which consists of a counter symbol and a non-negative integer weight. Each weight must be a non-negative integer, and the additive tuples must be specified in order of descending weight; otherwise, the @counter-style is invalid and must be ignored.

Counter symbols may be strings, images, or identifiers, and the three types can be mixed in a single descriptor. Counter representations are constructed by concatenating counter symbols together. Identifiers are rendered as strings containing the same characters. Images are rendered as inline replaced elements. The default object size of an image counter symbol is a 1em by 1em square.

If using identifiers rather than strings to define the symbols, be aware of the syntax of identifiers. In particular, ascii non-letters like "*" are not identifiers, and so must be quoted in a string. Hex escapes, used in several of the counter styles defined in this specification, "eat" the following space (to allow a digit to follow a hex escape without ambiguity), so two spaces must be put after a hex escape to separate it from the following one, or else they'll be considered adjacent, and part of the same identifier.

3.9. Speech Synthesis: the ‘speak-as’ descriptor

Name: speak-as
Value: auto | numeric | alphabetic | bullet | <counter-style-name>
Initial: auto

A counter style can be constructed with a meaning that is obvious visually, but impossible to meaningfully represent via a speech synthesizer, or possible but nonsensical when naively read out. The ‘speak-as’ descriptor describes how to synthesize the spoken form of a counter formatted with the given counter style. Values have the following meanings:

auto
If the counter style's ‘system’ is ‘alphabetic’, this value computes to ‘alphabetic’. If the ‘system’ is ‘cyclic’, this value computes to ‘bullet’. Otherwise, this value computes to ‘numeric’.
numeric
The counter's value is spoken as a number in the document language.
alphabetic
Generate a counter representation for the value as normal, then spell it out letter-by-letter in the document language. If the UA does not know how to pronounce the symbols, it may handle it as ‘numeric’.

For example, ‘lower-greek’ in English would be read out as "alpha", "beta", "gamma", etc. Conversely, ‘upper-latin’ in French would be read out as (in phonetic notation) /a/, /be/, /se/, etc.

bullet
The UA speaks a UA-defined phrase or audio cue that represents a list item being read out.
<counter-style-name>
The counter's value is instead spoken out in the specific style. If the specified style does not exist, this value is treated as ‘auto’.

The ability to defer pronunciation to another counter style can help when the symbols being used aren't actually letters. For example, here's a possible definition of a ‘circled-lower-latin’ counter-style, using some special unicode characters:

@counter-style circled-lower-latin {
  system: alphabetic;
  speak-as: lower-latin;
  symbols: ⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓟ ⓠ ⓡ ⓢ ⓣ ⓤ ⓥ ⓦ ⓧ ⓨ ⓩ;
  suffix: '';
}

Setting its ‘system’ to ‘alphabetic’ would normally make the UA try to read out the names of the characters, but in this case that might be something like "Circled Letter A", which is unlikely to make sense. Instead, explicitly setting ‘speak-as’ to ‘lower-latin’ ensures that they get read out as their corresponding latin letters, as intended.

4. Defining Anonymous Counter Styles: the ‘symbols()’ function

The ‘symbols()’ function allows a counter style to be defined inline in a property value, for when a style is used only once in a stylesheet and defining a full ‘@counter-style’ rule would be overkill. It does not provide the full feature-set of the ‘@counter-style’ rule, but provides a sufficient subset to still be useful. The syntax of the ‘symbols()’ rule is:

<symbols-function> = symbols( <symbols-type>? [ <string> | <image> ]+ )

Where <symbols-type> is one of the following keywords: ‘cyclic’, ‘numeric’, ‘alphabetic’, ‘symbolic’, or ‘fixed’.

The ‘symbols()’ function defines an anonymous counter style with no name, a prefix and suffix of ‘""’ (the empty string), a range of ‘auto’, a fallback style of ‘decimal’, and a negative sign of "\2D" ("-" hyphen-minus). The counter style's algorithm is constructed by consulting the previous chapter using the provided system — or ‘symbolic’ if the system was omitted — and the provided <string>s and <image>s as the value of the ‘symbols’ property. If the system is ‘fixed’, the first symbol value is ‘1’.

This code:

ol { list-style: symbols("*" "\2020" "\2021" "\A7"); }

will produce lists that look like:

*   One
†   Two
‡   Three
§   Four
**  Five
††  Six
‡‡  Seven

On the other hand, specifying the system of counter, like so:

ol { list-style: symbols(cyclic "*" "\2020" "\2021" "\A7"); }

will produce lists that look like:

*   One
†   Two
‡   Three
§   Four
*   Five
†   Six
‡   Seven

Note that the ‘symbols()’ function only allows strings and images, while the ‘symbols’ descriptor of a ‘@counter-style’ rule also allows identifiers.

5. Simple Predefined Counter Styles

The following stylesheet uses the ‘@counter-style’ rule to redefine all of the counter styles defined in CSS 2 and CSS 2.1. This stylesheet is normative - UAs must include it in their UA stylesheet (or at least act as if these rules were defined at that level).

5.1. Numeric: ‘decimal’, ‘decimal-leading-zero’, ‘cjk-decimal’, ‘lower-roman’, ‘upper-roman’, ‘armenian’, ‘georgian’, ‘hebrew

decimal
Western decimal numbers (e.g., 1, 2, 3, ..., 98, 99, 100).
decimal-leading-zero
Decimal numbers padded by initial zeros (e.g., 01, 02, 03, ..., 98, 99, 100).
cjk-decimal
Han decimal numbers (e.g., 一, 二, 三, ..., 九八, 九九, 一〇〇).
lower-roman
Lowercase ASCII Roman numerals (e.g., i, ii, iii, ..., xcviii, xcix, c).
upper-roman
Uppercase ASCII Roman numerals (e.g., I, II, III, ..., XCVIII, XCIX, C).
armenian
Traditional uppercase Armenian numbering (e.g., Ա, Բ, Գ, ..., ՂԸ, ՂԹ, Ճ).
georgian
Traditional Georgian numbering (e.g., ა, ბ, გ, ..., ჟჱ, ჟთ, რ).
hebrew
Traditional Hebrew numbering (e.g., א‎, ב‎, ג‎, ..., צח‎, צט‎, ק‎).

The ‘decimal’ counter-style must not be overridable with a ‘@counter-style’ rule, so that it is always available as an ultimate fallback style.

The following stylesheet fragment provides the normative definition of these predefined counter styles:


@counter-style decimal {
	system: numeric;
	symbols: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9';
}

@counter-style decimal-leading-zero {
	system: fixed -9;
	symbols: '-09' '-08' '-07' '-06' '-05' '-04' '-03' '-02' '-01' '00' '01' '02' '03' '04' '05' '06' '07' '08' '09';
}

@counter-style cjk-decimal {
	system: numeric;
	symbols: \3007  \4E00  \4E8C  \4E09  \56DB  \4E94  \516D  \4E03  \516B  \4E5D;
	/* 〇 一 二 三 四 五 六 七 八 九 */
	suffix: '\3001';
	/* "、" */
}

@counter-style lower-roman {
	system: additive;
	range: 1 4999;
	additive-symbols: 1000 m, 900 cm, 500 d, 400 cd, 100 c, 90 xc, 50 l, 40 xl, 10 x, 9 ix, 5 v, 4 iv, 1 i;
}

@counter-style upper-roman {
	system: additive;
	range: 1 4999;
	additive-symbols: 1000 M, 900 CM, 500 D, 400 CD, 100 C, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I;
}

@counter-style armenian {
	system: additive;
	range: 1 9999;
	additive-symbols: 9000 \554, 8000 \553, 7000 \552, 6000 \551, 5000 \550, 4000 \54F, 3000 \54E, 2000 \54D, 1000 \54C, 900 \54B, 800 \54A, 700 \549, 600 \548, 500 \547, 400 \546, 300 \545, 200 \544, 100 \543, 90 \542, 80 \541, 70 \540, 60 \53F, 50 \53E, 40 \53D, 30 \53C, 20 \53B, 10 \53A, 9 \539, 8 \538, 7 \537, 6 \536, 5 \535, 4 \534, 3 \533, 2 \532, 1 \531;
	/* 9000 Ք, 8000 Փ, 7000 Ւ, 6000 Ց, 5000 Ր, 4000 Տ, 3000 Վ, 2000 Ս, 1000 Ռ, 900 Ջ, 800 Պ, 700 Չ, 600 Ո, 500 Շ, 400 Ն, 300 Յ, 200 Մ, 100 Ճ, 90 Ղ, 80 Ձ, 70 Հ, 60 Կ, 50 Ծ, 40 Խ, 30 Լ, 20 Ի, 10 Ժ, 9 Թ, 8 Ը, 7 Է, 6 Զ, 5 Ե, 4 Դ, 3 Գ, 2 Բ, 1 Ա */
}

@counter-style georgian {
	system: additive;
	range: 1 19999;
	additive-symbols: 10000 \10F5, 9000 \10F0, 8000 \10EF, 7000 \10F4, 6000 \10EE, 5000 \10ED, 4000 \10EC, 3000 \10EB, 2000 \10EA, 1000 \10E9, 900 \10E8, 800 \10E7, 700 \10E6, 600 \10E5, 500 \10E4, 400 \10F3, 300 \10E2, 200 \10E1, 100 \10E0, 90 \10DF, 80 \10DE, 70 \10DD, 60 \10F2, 50 \10DC, 40 \10DB, 30 \10DA, 20 \10D9, 10 \10D8, 9 \10D7, 8 \10F1, 7 \10D6, 6 \10D5, 5 \10D4, 4 \10D3, 3 \10D2, 2 \10D1, 1 \10D0;
	/* 10000 ჵ, 9000 ჰ, 8000 ჯ, 7000 ჴ, 6000 ხ, 5000 ჭ, 4000 წ, 3000 ძ, 2000 ც, 1000 ჩ, 900 შ, 800 ყ, 700 ღ, 600 ქ, 500 ფ, 400 ჳ, 300 ტ, 200 ს, 100 რ, 90 ჟ, 80 პ, 70 ო, 60 ჲ, 50 ნ, 40 მ, 30 ლ, 20 კ, 10 ი, 9 თ, 8 ჱ, 7 ზ, 6 ვ, 5 ე, 4 დ, 3 გ, 2 ბ, 1 ა */
}

@counter-style hebrew {
	system: additive;
	range: 1 infinite;
	additive-symbols: 400 \5EA, 300 \5E9, 200 \5E8, 100 \5E7, 90 \5E6, 80 \5E4, 70 \5E2, 60 \5E1, 50 \5E0, 40 \5DE, 30 \5DC, 20 \5DB, 19 \5D9\5D8, 18 \5D9\5D7, 17 \5D9\5D6, 16 \5D8\5D6, 15 \5D8\5D5, 10 \5D9, 9 \5D8, 8 \5D7, 7 \5D6, 6 \5D5, 5 \5D4, 4 \5D3, 3 \5D2, 2 \5D1, 1 \5D0;
	/* 400 ת, 300 ש, 200 ר, 100 ק, 90 צ, 80 פ, 70 ע, 60 ס, 50 נ, 40 מ, 30 ל, 20 כ, 19 יט, 18 יח, 17 יז, 16 טז, 15 טו, 10 י, 9 ט, 8 ח, 7 ז, 6 ו, 5 ה, 4 ד, 3 ג, 2 ב, 1 א */
	/* This system manually specifies the values for 19-15 to force the correct display of 15 and 16, which are commonly rewritten to avoid a close resemblance to the Tetragrammaton. */
}

5.2. Alphabetic: ‘lower-alpha’, ‘lower-latin’, ‘upper-alpha’, ‘upper-latin’, ‘lower-greek’, ‘hiragana’, ‘hiragana-iroha’, ‘katakana’, ‘katakana-iroha

lower-alpha
lower-latin
Lowercase ASCII letters (e.g., a, b, c, ..., z, aa, ab).
upper-alpha
upper-latin
Uppercase ASCII letters (e.g., A, B, C, ..., Z, AA, AB).
lower-greek
Lowercase classical Greek (e.g., α, β, γ, ..., ω, αα, αβ).
hiragana
Dictionary-order hiragana lettering (e.g., あ, い, う, ..., ん, ああ, あい).
hiragana-iroha
Iroha-order hiragana lettering (e.g., い, ろ, は, ..., ん, いい, いろ).
katakana
Dictionary-order katakana lettering (e.g., ア, イ, ウ, ..., ン, アア, アイ).
katakana-iroha
Iroha-order katakana lettering (e.g., イ, ロ, ハ, ..., ン, イイ, イロ)

The following stylesheet fragment provides the normative definition of these predefined counter styles:


@counter-style lower-alpha {
	system: alphabetic;
	symbols: a b c d e f g h i j k l m n o p q r s t u v w x y z;
}

@counter-style lower-latin {
	system: override lower-alpha;
}

@counter-style upper-alpha {
	system: alphabetic;
	symbols: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z;
}

@counter-style upper-latin {
	system: override upper-alpha;
}

@counter-style lower-greek {
	system: alphabetic;
	symbols: \3B1  \3B2  \3B3  \3B4  \3B5  \3B6  \3B7  \3B8  \3B9  \3BA  \3BB  \3BC  \3BD  \3BE  \3BF  \3C0  \3C1  \3C3  \3C4  \3C5  \3C6  \3C7  \3C8  \3C9;
	/* α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω */
}

@counter-style hiragana {
	system: alphabetic;
	symbols: \3042  \3044  \3046  \3048  \304A  \304B  \304D  \304F  \3051  \3053  \3055  \3057  \3059  \305B  \305D  \305F  \3061  \3064  \3066  \3068  \306A  \306B  \306C  \306D  \306E  \306F  \3072  \3075  \3078  \307B  \307E  \307F  \3080  \3081  \3082  \3084  \3086  \3088  \3089  \308A  \308B  \308C  \308D  \308F  \3092  \3093;
	/* あ い う え お か き く け こ さ し す せ そ た ち つ て と な に ぬ ね の は ひ ふ へ ほ ま み む め も や ゆ よ ら り る れ ろ わ を ん */
	suffix: '、';
}

@counter-style hiragana-iroha {
	system: alphabetic;
	symbols: \3044  \308D  \306F  \306B  \307B  \3078  \3068  \3061  \308A  \306C  \308B  \3092  \308F  \304B  \3088  \305F  \308C  \305D  \3064  \306D  \306A  \3089  \3080  \3046  \3090  \306E  \304A  \304F  \3084  \307E  \3051  \3075  \3053  \3048  \3066  \3042  \3055  \304D  \3086  \3081  \307F  \3057  \3091  \3072  \3082  \305B  \3059  \3093;
	/* い ろ は に ほ へ と ち り ぬ る を わ か よ た れ そ つ ね な ら む う ゐ の お く や ま け ふ こ え て あ さ き ゆ め み し ゑ ひ も せ す ん */
	suffix: '、';
}

@counter-style katakana {
	system: alphabetic;
	symbols: \30A2  \30A4  \30A6  \30A8  \30AA  \30AB  \30AD  \30AF  \30B1  \30B3  \30B5  \30B7  \30B9  \30BB  \30BD  \30BF  \30C1  \30C4  \30C6  \30C8  \30CA  \30CB  \30CC  \30CD  \30CE  \30CF  \30D2  \30D5  \30D8  \30DB  \30DE  \30DF  \30E0  \30E1  \30E2  \30E4  \30E6  \30E8  \30E9  \30EA  \30EB  \30EC  \30ED  \30EF  \30F2  \30F3;
	/* ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン */
	suffix: '、';
}

@counter-style katakana-iroha {
	system: alphabetic;
	symbols: \30A4  \30ED  \30CF  \30CB  \30DB  \30D8  \30C8  \30C1  \30EA  \30CC  \30EB  \30F2  \30EF  \30AB  \30E8  \30BF  \30EC  \30BD  \30C4  \30CD  \30CA  \30E9  \30E0  \30A6  \30F0  \30CE  \30AA  \30AF  \30E4  \30DE  \30B1  \30D5  \30B3  \30A8  \30C6  \30A2  \30B5  \30AD  \30E6  \30E1  \30DF  \30B7  \30F1  \30D2  \30E2  \30BB  \30B9  \30F3;
	/* イ ロ ハ ニ ホ ヘ ト チ リ ヌ ル ヲ ワ カ ヨ タ レ ソ ツ ネ ナ ラ ム ウ ヰ ノ オ ク ヤ マ ケ フ コ エ テ ア サ キ ユ メ ミ シ ヱ ヒ モ セ ス ン */
	suffix: '、';
}

5.3. Symbolic: ‘disc’, ‘circle’, ‘square’, ‘disclosure-open’, ‘disclosure-closed

disc
A filled circle, similar to • U+2022 BULLET.
circle
A hollow circle, similar to ◦ U+25E6 WHITE BULLET.
square
A filled square, similar to ◾ U+25FE BLACK MEDIUM SMALL SQUARE.
disclosure-open
disclosure-closed
Symbols appropriate for indicating an open or closed disclosure widget, such as the HTML <details> element.

The following stylesheet fragment provides the normative definition of these predefined counter styles:

@counter-style disc {
	system: cyclic;
	symbols: \2022;
	/* • */
	suffix: '';
}

@counter-style circle {
	system: cyclic;
	symbols: \25E6;
	/* ◦ */
	suffix: '';
}

@counter-style square {
	system: cyclic;
	symbols: \25FE;
	/* ◾ */
	suffix: '';
}

@counter-style disclosure-open {
	system: cyclic;
	suffix: '';
	/* for symbols, see normative text below */
}

@counter-style disclosure-closed {
	system: cyclic;
	suffix: '';
	/* for symbols, see normative text below */
}

Alternately, a browser may render these styles using a browser-generated image instead of the defined character. If so, the image must look similar to the character, and must be sized to attractively fill a 1em by 1em square.

For the ‘disclosure-open’ and ‘disclosure-closed’ counter styles, the marker must be an image or character suitable for indicating the open and closed states of a disclosure widget, such as HTML's <details> element. If the image is directional, it must respond to the writing mode of the element [CSS3-WRITING-MODES], similar to the bidi-sensitive images feature of the Images 4 module. For example, the ‘disclosure-closed’ style might use the characters U+25B8 BLACK RIGHT-POINTING SMALL TRIANGLE (▸) and U+25C2 BLACK LEFT-POINTING SMALL TRIANGLE (◂), while the ‘disclosure-open’ style might use the character U+25BE BLACK DOWN-POINTING SMALL TRIANGLE (▾).

6. Complex Predefined Counter Styles

While authors may define their own counter styles using the ‘@counter-style’ rule or rely on the set of predefined counter styles, a few counter styles are described by rules that are too complex to be captured by the predefined algorithms. These counter styles are described in this section.

Some of the counter styles specified in this section have custom algorithms for generating counter values, but are otherwise identical to a counter style defined via the ‘@counter-style’ rule. For example, an author can reference one of these styles in an ‘override’ system, reusing the algorithm but swapping out some of the other descriptors.

All of the counter styles defined in this section have a spoken form of ‘numeric’, and are all negative-capable.

6.1. Longhand East Asian Counter Styles: ‘japanese-informal’, ‘japanese-formal’, ‘korean-hangul-formal’, ‘korean-hanja-informal’, ‘korean-hanja-formal’, ‘simp-chinese-informal’, ‘simp-chinese-formal’, ‘trad-chinese-informal’, ‘trad-chinese-formal

Chinese, Japanese, and Korean have longhand counter styles, which have a structure similar to "one hundred thirteen thousand and twenty-three" in English. Each has both formal and informal variants. The formal styles are typically used in financial and legal documents, as their characters are more difficult to alter into each other.

japanese-informal
Informal Japanese Kanji numbering (e.g., 一万一千百十一)
japanese-formal
Formal Japanese Kanji numbering (e.g. 壱萬壱阡壱百壱拾壱)
korean-hangul-formal
Korean Hangul numbering (e.g., 일만 일천일백일십일)
korean-hanja-informal
Informal Korean Hanja numbering (e.g., 萬 一千百十一)
korean-hanja-formal
Forman Korean Han (Hanja) numbering (e.g., 壹萬 壹仟壹百壹拾壹)
simp-chinese-informal
Simplified Chinese informal numbering (e.g., 一万一千一百一十一)
simp-chinese-formal
Simplified Chinese formal numbering (e.g. 壹万壹仟壹佰壹拾壹)
trad-chinese-informal
Traditional Chinese informal numbering (e.g., 一萬一千一百一十一)
trad-chinese-formal
Traditional Chinese informal numbering (e.g., 壹萬壹仟壹佰壹拾壹)
cjk-ideographic
This counter style is identical to ‘trad-chinese-informal’. (It exists for legacy reasons.)

The examples above show the number 11,111, which is not often used as a counter value, but illustrates the differences among the systems.

The following table shows examples of these styles, particularly some ways in which they differ.
Counter Style 0 1 2 3 10 11 99 100 101 10,000
japanese-informal一十 一十一 九十九 一百 一百一 一万
japanese-formal壱拾 壱拾壱 九拾九 壱百 壱百壱 壱萬
korean-hangul-formal일십 일십일 구십구 일백 일백일 일만
korean-hanja-informal一十 一十一 九十九 一百 一百一
korean-hanja-formal壹拾 壹拾壹 九拾九 壹百 壹百壹 壹萬
simp-chinese-informal十一 九十九 一百 一百零一 一万
simp-chinese-formal壹拾 壹拾壹 玖拾玖 壹佰 壹佰零壹 壹万
trad-chinese-informal十一 九十九 一百 一百零一 一萬
trad-chinese-formal壹拾 壹拾壹 玖拾玖 壹佰 壹佰零壹 壹萬

The Korean and Japanese variants of these counter styles can, if limited from 0 to 9999, be expressed as ‘@counter-style’ rules. Thus, the implementation details are split into two sections: a required section defining the styles over this limited range, and an optional section defining them over a much larger range that requires custom algorithms for all of the styles.

6.1.1. Limited-range Implementation (required)

Japanese
@counter-style japanese-informal {
	system: additive;
	range: -9999 9999;
	additive-symbols: 9000 \4E5D\5343, 8000 \516B\5343, 7000 \4E03\5343, 6000 \516D\5343, 5000 \4E94\5343, 4000 \56DB\5343, 3000 \4E09\5343, 2000 \4E8C\5343, 1000 \5343, 900 \4E5D\767E, 800 \516B\767E, 700 \4E03\767E, 600 \516D\767E, 500 \4E94\767E, 400 \56DB\767E, 300 \4E09\767E, 200 \4E8C\767E, 100 \767E, 90 \4E5D\5341, 80 \516B\5341, 70 \4E03\5341, 60 \516D\5341, 50 \4E94\5341, 40 \56DB\5341, 30 \4E09\5341, 20 \4E8C\5341, 10 \5341, 9 \4E5D, 8 \516B, 7 \4E03, 6 \516D, 5 \4E94, 4 \56DB, 3 \4E09, 2 \4E8C, 1 \4E00, 0 \3007;
	/* 9000 九千, 8000 八千, 7000 七千, 6000 六千, 5000 五千, 4000 四千, 3000 三千, 2000 二千, 1000 千, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 三百, 200 二百, 100 百, 90 九十, 80 八十, 70 七十, 60 六十, 50 五十, 40 四十, 30 三十, 20 二十, 10 十, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 三, 2 二, 1 一, 0 〇 */
	suffix: '\3001';
	/* 、 */
	negative: "\30DE\30A4\30CA\30B9";
	/* マイナス */
	fallback: cjk-decimal;
}

@counter-style japanese-formal {
	system: additive;
	range: -9999 9999;
	additive-symbols: 9000 \4E5D\9621, 8000 \516B\9621, 7000 \4E03\9621, 6000 \516D\9621, 5000 \4F0D\9621, 4000 \56DB\9621, 3000 \53C2\9621, 2000 \5F10\9621, 1000 \58F1\9621, 900 \4E5D\767E, 800 \516B\767E, 700 \4E03\767E, 600 \516D\767E, 500 \4F0D\767E, 400 \56DB\767E, 300 \53C2\767E, 200 \5F10\767E, 100 \58F1\767E, 90 \4E5D\62FE, 80 \516B\62FE, 70 \4E03\62FE, 60 \516D\62FE, 50 \4F0D\62FE, 40 \56DB\62FE, 30 \53C2\62FE, 20 \5F10\62FE, 10 \58F1\62FE, 9 \4E5D, 8 \516B, 7 \4E03, 6 \516D, 5 \4F0D, 4 \56DB, 3 \53C2, 2 \5F10, 1 \58F1, 0 \96F6;
	/* 9000 九阡, 8000 八阡, 7000 七阡, 6000 六阡, 5000 伍阡, 4000 四阡, 3000 参阡, 2000 弐阡, 1000 壱阡, 900 九百, 800 八百, 700 七百, 600 六百, 500 伍百, 400 四百, 300 参百, 200 弐百, 100 壱百, 90 九拾, 80 八拾, 70 七拾, 60 六拾, 50 伍拾, 40 四拾, 30 参拾, 20 弐拾, 10 壱拾, 9 九, 8 八, 7 七, 6 六, 5 伍, 4 四, 3 参, 2 弐, 1 壱, 0 零 */
	suffix: '\3001';
	/* 、 */
	negative: "\30DE\30A4\30CA\30B9";
	/* マイナス */
	fallback: cjk-decimal;
}
Korean
@counter-style korean-hangul-formal {
	system: additive;
	range: 0 9999;
	additive-symbols: 9000 \AD6C\CC9C, 8000 \D314\CC9C, 7000 \CE60\CC9C, 6000 \C721\CC9C, 5000 \C624\CC9C, 4000 \C0AC\CC9C, 3000 \C0BC\CC9C, 2000 \C774\CC9C, 1000 \C77C\CC9C, 900 \AD6C\BC31, 800 \D314\BC31, 700 \CE60\BC31, 600 \C721\BC31, 500 \C624\BC31, 400 \C0AC\BC31, 300 \C0BC\BC31, 200 \C774\BC31, 100 \C77C\BC31, 90 \AD6C\C2ED, 80 \D314\C2ED, 70 \CE60\C2ED, 60 \C721\C2ED, 50 \C624\C2ED, 40 \C0AC\C2ED, 30 \C0BC\C2ED, 20 \C774\C2ED, 10 \C77C\C2ED, 9 \AD6C, 8 \D314, 7 \CE60, 6 \C721, 5 \C624, 4 \C0AC, 3 \C0BC, 2 \C774, 1 \C77C, 0 \C601;
	/* 9000 구천, 8000 팔천, 7000 칠천, 6000 육천, 5000 오천, 4000 사천, 3000 삼천, 2000 이천, 1000 일천, 900 구백, 800 팔백, 700 칠백, 600 육백, 500 오백, 400 사백, 300 삼백, 200 이백, 100 일백, 90 구십, 80 팔십, 70 칠십, 60 육십, 50 오십, 40 사십, 30 삼십, 20 이십, 10 일십, 9 구, 8 팔, 7 칠, 6 육, 5 오, 4 사, 3 삼, 2 이, 1 일, 0 영 */
	suffix: '\3001';
	/* 、 */
}

@counter-style korean-hanja-informal {
	system: additive;
	range: 0 9999;
	additive-symbols: 9000 \4E5D\5343, 8000 \516B\5343, 7000 \4E03\5343, 6000 \516D\5343, 5000 \4E94\5343, 4000 \56DB\5343, 3000 \4E09\5343, 2000 \4E8C\5343, 1000 \5343, 900 \4E5D\767E, 800 \516B\767E, 700 \4E03\767E, 600 \516D\767E, 500 \4E94\767E, 400 \56DB\767E, 300 \4E09\767E, 200 \4E8C\767E, 100 \767E, 90 \4E5D\5341, 80 \516B\5341, 70 \4E03\5341, 60 \516D\5341, 50 \4E94\5341, 40 \56DB\5341, 30 \4E09\5341, 20 \4E8C\5341, 10 \5341, 9 \4E5D, 8 \516B, 7 \4E03, 6 \516D, 5 \4E94, 4 \56DB, 3 \4E09, 2 \4E8C, 1 \4E00, 0 \96F6;
	/* 9000 九千, 8000 八千, 7000 七千, 6000 六千, 5000 五千, 4000 四千, 3000 三千, 2000 二千, 1000 千, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 三百, 200 二百, 100 百, 90 九十, 80 八十, 70 七十, 60 六十, 50 五十, 40 四十, 30 三十, 20 二十, 10 十, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 三, 2 二, 1 一, 0 零 */
	suffix: '\3001';
	/* 、 */
}

@counter-style korean-hanja-formal {
	system: additive;
	range: 0 9999;
	additive-symbols: 9000 \4E5D\4EDF, 8000 \516B\4EDF, 7000 \4E03\4EDF, 6000 \516D\4EDF, 5000 \4E94\4EDF, 4000 \56DB\4EDF, 3000 \53C3\4EDF, 2000 \8CB3\4EDF, 1000 \58F9\4EDF, 900 \4E5D\767E, 800 \516B\767E, 700 \4E03\767E, 600 \516D\767E, 500 \4E94\767E, 400 \56DB\767E, 300 \53C3\767E, 200 \8CB3\767E, 100 \58F9\767E, 90 \4E5D\62FE, 80 \516B\62FE, 70 \4E03\62FE, 60 \516D\62FE, 50 \4E94\62FE, 40 \56DB\62FE, 30 \53C3\62FE, 20 \8CB3\62FE, 10 \58F9\62FE, 9 \4E5D, 8 \516B, 7 \4E03, 6 \516D, 5 \4E94, 4 \56DB, 3 \53C3, 2 \8CB3, 1 \58F9, 0 \96F6;
	/* 9000 九仟, 8000 八仟, 7000 七仟, 6000 六仟, 5000 五仟, 4000 四仟, 3000 參仟, 2000 貳仟, 1000 壹仟, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 參百, 200 貳百, 100 壹百, 90 九拾, 80 八拾, 70 七拾, 60 六拾, 50 五拾, 40 四拾, 30 參拾, 20 貳拾, 10 壹拾, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 參, 2 貳, 1 壹, 0 零 */
	suffix: '\3001';
	/* 、 */
}
Chinese

The Chinese longhand styles are defined over the range -9999 to 9999. For numbers outside this range, the ‘cjk-decimal’ style is used. All of the styles are defined by almost identical algorithms (specified as a single algorithm here, with the differences called out when relevant), but use different sets of characters. The list following the algorithm gives the name of each counter style using this algorithm, and the individual character sets used by each style.

  1. If the counter value is 0, the representation is the character for 0 specified for the given counter style. Skip the rest of this algorithm.
  2. Initially represent the counter value as a decimal number. For each digit that is not 0, append the appropriate digit marker to the digit. The ones digit has no marker.
  3. For the informal styles, if the counter value is between ten and nineteen, remove the tens digit (leave the digit marker).
  4. Drop any trailing zeros and collapse any remaining zeros into a single zero digit.
  5. Replace the digits 0-9 with the appropriate character for the given counter style. Return the resultant string as the representation of the counter value.

For all of these counter styles, the suffix descriptor is "、" U+3001, the fallback descriptor is ‘cjk-decimal’, the lower bound descriptor is -9999, the upper bound descriptor is 9999, and the negative sign is given in the table of symbols for each style.

The following tables define the characters used in these styles:

Values Codepoints
simp-chinese-informal simp-chinese-formal trad-chinese-informal trad-chinese-formal
Digit 0 零 U+96F6 零 U+96F6 零 U+96F6 零 U+96F6
Digit 1 一 U+4E00 壹 U+58F9 一 U+4E00 壹 U+58F9
Digit 2 二 U+4E8C 贰 U+8D30 二 U+4E8C 貳 U+8CB3
Digit 3 三 U+4E09 叁 U+53C1 三 U+4E09 參 U+53C3
Digit 4 四 U+56DB 肆 U+8086 四 U+56DB 肆 U+8086
Digit 5 五 U+4E94 伍 U+4F0D 五 U+4E94 伍 U+4F0D
Digit 6 六 U+516D 陆 U+9646 六 U+516D 陸 U+9678
Digit 7 七 U+4E03 柒 U+67D2 七 U+4E03 柒 U+67D2
Digit 8 八 U+516B 捌 U+634C 八 U+516B 捌 U+634C
Digit 9 九 U+4E5D 玖 U+7396 九 U+4E5D 玖 U+7396
Tens Digit Marker 十 U+5341 拾 U+62FE 十 U+5341 拾 U+62FE
Hundreds Digit Marker 百 U+767E 佰 U+4F70 百 U+767E 佰 U+4F70
Thousands Digit Marker 千 U+5343 仟 U+4EDF 千 U+5343 仟 U+4EDF
Negative Sign 负 U+8D1F 负 U+8D1F 負 U+8CA0 負 U+8CA0

For reference, here are the first 120 values for the ‘simp-chinese-informal’ style:

  1     一    41   四十一    81   八十一
  2     二    42   四十二    82   八十二
  3     三    43   四十三    83   八十三
  4     四    44   四十四    84   八十四
  5     五    45   四十五    85   八十五
  6     六    46   四十六    86   八十六
  7     七    47   四十七    87   八十七
  8     八    48   四十八    88   八十八
  9     九    49   四十九    89   八十九
 10     十    50    五十    90    九十
 11    十一    51   五十一    91   九十一
 12    十二    52   五十二    92   九十二
 13    十三    53   五十三    93   九十三
 14    十四    54   五十四    94   九十四
 15    十五    55   五十五    95   九十五
 16    十六    56   五十六    96   九十六
 17    十七    57   五十七    97   九十七
 18    十八    58   五十八    98   九十八
 19    十九    59   五十九    99   九十九
 20    二十    60    六十   100    一百
 21   二十一    61   六十一   101  一百零一
 22   二十二    62   六十二   102  一百零二
 23   二十三    63   六十三   103  一百零三
 24   二十四    64   六十四   104  一百零四
 25   二十五    65   六十五   105  一百零五
 26   二十六    66   六十六   106  一百零六
 27   二十七    67   六十七   107  一百零七
 28   二十八    68   六十八   108  一百零八
 29   二十九    69   六十九   109  一百零九
 30    三十    70    七十   110  一百一十
 31   三十一    71   七十一   111 一百一十一
 32   三十二    72   七十二   112 一百一十二
 33   三十三    73   七十三   113 一百一十三
 34   三十四    74   七十四   114 一百一十四
 35   三十五    75   七十五   115 一百一十五
 36   三十六    76   七十六   116 一百一十六
 37   三十七    77   七十七   117 一百一十七
 38   三十八    78   七十八   118 一百一十八
 39   三十九    79   七十九   119 一百一十九
 40    四十    80    八十   120  一百二十

6.1.2. Extended Implementation (optional)

Some counter styles described in earlier chapters have been limited to an artifically small (though still useful) range to reduce the overall complexity of the spec and the task of implementing those styles. However, some implementations might consider the extra complexity worthwhile for the additional range it offers to authors. To accomodate this, this section describes how to extend the limited counter-styles to a larger range.

This entire section is normative, but optional. User-agents may ignore it and still be conformant. If a user-agent implements some of the extended forms described in this section, they must be implemented as described here.

The Chinese longhand styles are defined out to 10k with a specialized algorithm, while the Japanese and Korean longhand styles are defined similarly as ‘additive’ styles. However, these styles are defined out to 1016 in common usage. The following section describes an alternative algorithm for these styles.

The Chinese and Japanese styles are defined for all numbers between -1016 and 1016, exclusive; the Korean styles are defined for all non-negative numbers less than 1016. For numbers outside this range, the ‘cjk-decimal’ style is used. All of the styles are defined by almost identical algorithms (specified as a single algorithm here, with the differences called out when relevant), but use different sets of characters. The list following the algorithm gives the name of each counter style using this algorithm, and the individual character sets used by each style.

  1. If the counter value is 0, the representation is the character for 0 specified for the given counter style. Skip the rest of this algorithm.
  2. Initially represent the counter value as a decimal number. Starting from the right (ones place), split the decimal number into groups of four digits.
  3. For each group with a non-zero value, append the appropriate group marker to the group. The ones group has no marker.
  4. Within each group, for each digit that is not 0, append the appropriate digit marker to the digit. The ones digit of each group has no marker.
  5. Drop ones:
  6. Drop zeros:
  7. For the Korean styles, insert a space (" " U+0020) between each group.
  8. Replace the digits 0-9 with the appropriate character for the given counter style. Return the resultant string as the representation of the counter value.

For all of these counter styles, the suffix descriptor is "、" U+3001, the fallback descriptor is ‘cjk-decimal’, and the negative sign is given in the tables below, or else is the initial value of the descriptor. For Chinese and Japanese, the lower range bound descriptor is -9999 9999 9999 9999 (-1016+1), while for Korean it's 0. For all of them, the upper range bound descriptor is 9999 9999 9999 9999 (1016-1).

The following tables define the characters used in these styles:

Values Codepoints
simp-chinese-informal simp-chinese-formal trad-chinese-informal trad-chinese-formal
Digit 0 零 U+96F6 零 U+96F6 零 U+96F6 零 U+96F6
Digit 1 一 U+4E00 壹 U+58F9 一 U+4E00 壹 U+58F9
Digit 2 二 U+4E8C 贰 U+8D30 二 U+4E8C 貳 U+8CB3
Digit 3 三 U+4E09 叁 U+53C1 三 U+4E09 參 U+53C3
Digit 4 四 U+56DB 肆 U+8086 四 U+56DB 肆 U+8086
Digit 5 五 U+4E94 伍 U+4F0D 五 U+4E94 伍 U+4F0D
Digit 6 六 U+516D 陆 U+9646 六 U+516D 陸 U+9678
Digit 7 七 U+4E03 柒 U+67D2 七 U+4E03 柒 U+67D2
Digit 8 八 U+516B 捌 U+634C 八 U+516B 捌 U+634C
Digit 9 九 U+4E5D 玖 U+7396 九 U+4E5D 玖 U+7396
Second Digit Marker 十 U+5341 拾 U+62FE 十 U+5341 拾 U+62FE
Third Digit Marker 百 U+767E 佰 U+4F70 百 U+767E 佰 U+4F70
Fourth Digit Marker 千 U+5343 仟 U+4EDF 千 U+5343 仟 U+4EDF
Second Group Marker 万 U+4E07 万 U+4E07 萬 U+842C 萬 U+842C
Third Group Marker 亿 U+4EBF 亿 U+4EBF 億 U+5104 億 U+5104
Fourth Group Marker 万亿 U+4E07 U+4EBF 万亿 U+4E07 U+4EBF 兆 U+5146 兆 U+5146
Negative Sign 负 U+8D1F 负 U+8D1F 負 U+8CA0 負 U+8CA0
Values Codepoints
japanese-informal japanese-formal
Digit 0 〇 U+3007 零 U+96F6
Digit 1 一 U+4E00 壱 U+58F1
Digit 2 二 U+4E8C 弐 U+5F10
Digit 3 三 U+4E09 参 U+53C2
Digit 4 四 U+56DB 四 U+56DB
Digit 5 五 U+4E94 伍 U+4f0D
Digit 6 六 U+516D 六 U+516D
Digit 7 七 U+4E03 七 U+4E03
Digit 8 八 U+516B 八 U+516B
Digit 9 九 U+4E5D 九 U+4E5D
Second Digit Marker 十 U+5341 拾 U+62FE
Third Digit Marker 百 U+767E 百 U+767E
Fourth Digit Marker 千 U+5343 阡 U+9621
Second Group Marker 万 U+4E07 萬 U+842C
Third Group Marker 億 U+5104 億 U+5104
Fourth Group Marker 兆 U+5146 兆 U+5146
Negative Sign マイナス U+30DE U+30A4 U+30CA U+30B9
Values Codepoints
korean-hangul-formal korean-hanja-informal korean-hanja-formal
Digit 0 영 U+C601 零 U+96F6 零 U+96F6
Digit 1 일 U+C77C 一 U+4E00 壹 U+58F9
Digit 2 이 U+C774 二 U+4E8C 貳 U+8CB3
Digit 3 삼 U+C0BC 三 U+4E09 參 U+53C3
Digit 4 사 U+C0AC 四 U+56DB 四 U+56DB
Digit 5 오 U+C624 五 U+4E94 五 U+4E94
Digit 6 육 U+C721 六 U+516D 六 U+516D
Digit 7 칠 U+CE60 七 U+4E03 七 U+4E03
Digit 8 팔 U+D314 八 U+516B 八 U+516B
Digit 9 구 U+AD6C 九 U+4E5D 九 U+4E5D
Second Digit Marker 십 U+C2ED 十 U+5341 拾 U+62FE
Third Digit Marker 백 U+BC31 百 U+767E 百 U+767E
Fourth Digit Marker 천 U+CC9C 千 U+5343 仟 U+4EDF
Second Group Marker 만 U+B9CC 萬 U+842C 萬 U+842C
Third Group Marker 억 U+C5B5 億 U+5104 億 U+5104
Fourth Group Marker 조 U+C870 兆 U+5146 兆 U+5146

6.2. Ethiopic Numeric Counter Style: ‘ethiopic-numeric

The ethiopic-numeric counter style is defined for all positive non-zero numbers. The following algorithm converts decimal digits to ethiopic numbers:

  1. Split the number into groups of two digits, starting with the least significant decimal digit.
  2. Index each group sequentially, starting from the least significant as group number zero.
  3. If the group has an odd index (as given in the previous step) and has the value 1, or if the group is the most significant one and has the value 1, or if the group has the value zero, then remove the digit (but leave the group, so it still has a separator appended below).
  4. For each remaining digit, substitute the relevant ethiopic character from the list below.
    Tens Units
    Values Codepoints Values Codepoints
    10 U+1372 1 U+1369
    20 U+1373 2 U+136A
    30 U+1374 3 U+136B
    40 U+1375 4 U+136C
    50 U+1376 5 U+136D
    60 U+1377 6 U+136E
    70 U+1378 7 U+136F
    80 U+1379 8 U+1370
    90 U+137A 9 U+1371
  5. For each group with an odd index (as given in the second step) that did not have its digits removed in the third step, append ፻ U+137B.
  6. For each group with an even index (as given in the second step), except the group with number 0, append ፼ U+137C.
  7. Concatenate the groups into one string.

For this system, the name is "ethiopic-numeric", the lower range bound descriptor is 1, the upper range bound descriptor is infinity, and the rest of the descriptors have their initial value.

Is there a better suffix to use than the initial (".")? The alphabetic ethiopic systems use a different suffix.

The decimal number 100, in ethiopic, is ፻ U+137B

The decimal number 78010092, in ethiopic, is ፸፰፻፩፼፺፪ U+1378 U+1370 U+137B U+1369 U+137C U+137A U+136A.

The decimal number 780000001092, in ethiopic, is ፸፰፻፩፼፼፺፪ U+1378 U+1370 U+137B U+1369 U+137C U+137C U+137A U+136A.

7. APIs

7.1. Extensions to the CSSRule interface

The CSSRule interface is extended as follows:

partial interface CSSRule {
    const unsigned short COUNTER_STYLE_RULE = 11;
}

7.2. The CSSCounterStyleRule interface

The CSSCounterStyleRule interface represents a ‘@counter-style’ rule.

interface CSSCounterStyleRule : CSSRule {
  readonly attribute DOMString name;
  readonly attribute DOMString system;
  readonly attribute DOMString symbols;
  readonly attribute DOMString additiveSymbols;
  readonly attribute DOMString negative;
  readonly attribute DOMString prefix;
  readonly attribute DOMString suffix;
  readonly attribute DOMString range;
  readonly attribute DOMString width;
  readonly attribute DOMString fallback;
}
name of type DOMString, readonly
The name attribute must return a DOMString object that contains the serialization of the <counter-style-name> defined for the associated ‘@counter-style’ block.
everything else
The remaining attributes must return a DOMString object that contains the serialization of the associated descriptor defined for the associated ‘@counter-style’ block.

8. Sample style sheet for HTML

This section is informative, not normative. HTML itself defines the styles that apply to its elements, and in some cases defers to the user agent's discretion.

details > summary {
	display: list-item;
	list-style: disclosure-closed inside;
}

details[open] > summary {
	list-style: disclosure-open inside;
}

Changes since the Oct 2012 Working Draft

Acknowledgments

The following people and documentation they wrote were very useful for defining the numbering systems: Alexander Savenkov, Arron Eicholz, Aryeh Gregor, Christopher Hoess, Daniel Yacob, Frank Tang, Jonathan Rosenne, Karl Ove Hufthammer, Musheg Arakelyan, Nariné Renard Karapetyan, Randall Bart, Richard Ishida, Simon Montagu (Mozilla, smontagu@smontagu.org)

Conformance

Document Conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Conformance Classes

Conformance to CSS Counter Styles Module is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to CSS Counter Styles Module if all of its declarations that use properties defined in this module have values that are valid according to the generic CSS grammar and the individual grammars of each property as given in this module.

A renderer is conformant to CSS Counter Styles Module if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by CSS Counter Styles Module by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to CSS Counter Styles Module if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial Implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Experimental Implementations

To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.

Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.

Non-Experimental Implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group's website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

References

Normative references

[CSS3-WRITING-MODES]
Elika J. Etemad; Koji Ishii. CSS Writing Modes Module Level 3. 15 November 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-css3-writing-modes-20121115/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt

Other references

[CSS3LIST]
Tab Atkins Jr. CSS Lists and Counters Module Level 3. 24 May 2011. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2011/WD-css3-lists-20110524

Descriptor index

Descriptor Values Initial
additive-symbols [ <integer> && <symbol> ]# N/A
fallback <counter-style-name> decimal
negative <symbol> <symbol>? "\2D" ("-" hyphen-minus)
prefix <symbol> "" (the empty string)
range [ [ <integer> | infinite ]{2} ]# | auto auto
speak-as auto | numeric | alphabetic | bullet | <counter-style-name> auto
suffix <symbol> "\2E" ("." full stop)
symbols <symbol>+ N/A
system cyclic | numeric | alphabetic | symbolic | additive | [fixed <integer>?] | [ override <counter-style-name> ] symbolic
width <integer> && <symbol> 0 ""

Index