8000 csswg-drafts/css-counter-styles/Overview.html at 8e2accefd38327ce55073684e5ab10174eda7a29 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
4076 lines (3148 loc) · 206 KB

File metadata and controls

4076 lines (3148 loc) · 206 KB
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Counter Styles Level 3</title>
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<style>
pre.stylesheet { white-space: pre-wrap; }
code.inline { display: inline-block; }
</style>
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/">
<img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72">
</a>
</p>
<h1 class="p-name no-ref" id="title">CSS Counter Styles Level 3</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft,
<time class="dt-updated" datetime="2015-01-15">15 January 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:</dt>
<dd><a class="u-url" href="http://dev.w3.org/csswg/css-counter-styles/">http://dev.w3.org/csswg/css-counter-styles/</a></dd>
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/css-counter-styles-3/">http://www.w3.org/TR/css-counter-styles-3/</a></dd>
<dt>Previous Versions:</dt>
<dd><a href="http://www.w3.org/TR/2014/WD-css-counter-styles-3-20140826/" rel="previous">http://www.w3.org/TR/2014/WD-css-counter-styles-3-20140826/</a></dd>
<dd><a href="http://www.w3.org/TR/2013/WD-css-counter-styles-3-20130718/" rel="previous">http://www.w3.org/TR/2013/WD-css-counter-styles-3-20130718/</a></dd>
<dd><a href="http://www.w3.org/TR/2013/WD-css-counter-styles-3-20130221/" rel="previous">http://www.w3.org/TR/2013/WD-css-counter-styles-3-20130221/</a></dd>
<dd><a href="http://www.w3.org/TR/2012/WD-css-counter-styles-3-20121009/" rel="previous">http://www.w3.org/TR/2012/WD-css-counter-styles-3-20121009/</a></dd>
<dt>Feedback:</dt>
<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-counter-styles%5D%20feedback">www-style@w3.org</a> with subject line “<kbd>[css-counter-styles] <var>… message topic …</var></kbd>” (<a href="http://lists.w3.org/Archives/Public/www-style/" rel="discussion">archives</a>)</span></dd>
<dt>Issue Tracking:</dt>
<dd><a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=CSS&amp;component=Counter%20Styles&amp;resolution=---">Bugzilla</a></dd>
<dt class="editor">Editor:</dt>
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-url url" href="http://xanthir.com/contact/">Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)</div>
</dd>
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2014 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This module introduces the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule, which allows authors to define their own custom counter styles for use with CSS list-marker and generated-content counters <a data-biblio-type="informative" data-link-type="biblio" href="#biblio-css3list" title="CSS3LIST">[CSS3LIST]</a>. It also predefines a set of common counter styles, including the ones present in CSS2 and CSS2.1.</p>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
</p>
<p>
The (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-counter-styles%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href="http://www.w3.org/Mail/Request">instructions</a>)
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] <em>…summary of comment…</em>”
</p>
<p>
This document was produced by the <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
(part of the <a href="http://www.w3.org/Style/">Style Activity</a>).
</p>
<p>
This document was produced by a group operating under
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a>
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 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
</p>
<p>
This document is governed by the <a href="http://www.w3.org/2014/Process-20140801/">1 August 2014 W3C Process Document</a>.
</p></div>
<div data-fill-with="at-risk"></div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">
Introduction</span></a></li>
<li><a href="#counter-styles"><span class="secno">2</span> <span class="content">
Counter Styles</span></a></li>
<li><a href="#the-counter-style-rule"><span class="secno">3</span> <span class="content">
Defining Custom Counter Styles: the <span class="css" data-link-type="maybe" title="@counter-style">@counter-style</span> rule</span></a>
<ul class="toc">
<li><a href="#counter-style-system"><span class="secno">3.1</span> <span class="content">
Counter algorithms: the <span class="property" data-link-type="propdesc" title="system">system</span> descriptor</span></a>
<ul class="toc">
<li><a href="#cyclic-system"><span class="secno">3.1.1</span> <span class="content">
Cycling Symbols: the <span class="css" data-link-type="maybe" title="cyclic">cyclic</span> system</span></a></li>
<li><a href="#fixed-system"><span class="secno">3.1.2</span> <span class="content">
Exhaustible Symbols: the <span class="css" data-link-type="maybe" title="fixed">fixed</span> system</span></a></li>
<li><a href="#symbolic-system"><span class="secno">3.1.3</span> <span class="content">
Repeating Symbols: the <span class="css" data-link-type="maybe" title="symbolic">symbolic</span> system</span></a></li>
<li><a href="#alphabetic-system"><span class="secno">3.1.4</span> <span class="content">
Bijective Numerals: the <span class="css" data-link-type="maybe" title="alphabetic">alphabetic</span> system</span></a></li>
<li><a href="#numeric-system"><span class="secno">3.1.5</span> <span class="content">
Positional Numerals: the <span class="css" data-link-type="maybe" title="numeric">numeric</span> system</span></a></li>
<li><a href="#additive-system"><span class="secno">3.1.6</span> <span class="content">
Accumulating Numerals: the <span class="css" data-link-type="maybe" title="additive">additive</span> system</span></a></li>
<li><a href="#extends-system"><span class="secno">3.1.7</span> <span class="content">
Building from Existing Counter Styles: the <span class="css" data-link-type="maybe" title="extends">extends</span> system
<span></span></span></a></li>
</ul>
</li>
<li><a href="#counter-style-negative"><span class="secno">3.2</span> <span class="content">
Formatting negative values: the <span class="property" data-link-type="propdesc" title="negative">negative</span> descriptor</span></a></li>
<li><a href="#counter-style-prefix"><span class="secno">3.3</span> <span class="content">
Symbols before the marker: the <span class="property" data-link-type="propdesc" title="prefix">prefix</span> descriptor</span></a></li>
<li><a href="#counter-style-suffix"><span class="secno">3.4</span> <span class="content">
Symbols after the marker: the <span class="property" data-link-type="propdesc" title="suffix">suffix</span> descriptor</span></a></li>
<li><a href="#counter-style-range"><span class="secno">3.5</span> <span class="content">
Limiting the counter scope: the <span class="property" data-link-type="propdesc" title="range">range</span> descriptor</span></a></li>
<li><a href="#counter-style-pad"><span class="secno">3.6</span> <span class="content">
Zero-Padding and Constant-Width Representations: the <span class="property" data-link-type="propdesc" title="pad">pad</span> descriptor</span></a></li>
<li><a href="#counter-style-fallback"><span class="secno">3.7</span> <span class="content">
Defining fallback: the <span class="property" data-link-type="propdesc" title="fallback">fallback</span> descriptor</span></a></li>
<li><a href="#counter-style-symbols"><span class="secno">3.8</span> <span class="content">
Marker characters: the <span class="property" data-link-type="propdesc" title="symbols">symbols</span> and <span class="property" data-link-type="propdesc" title="additive-symbols">additive-symbols</span> descriptors</span></a></li>
<li><a href="#counter-style-speak-as"><span class="secno">3.9</span> <span class="content">
Speech Synthesis: the <span class="property" data-link-type="propdesc" title="speak-as">speak-as</span> descriptor</span></a></li>
</ul>
</li>
<li><a href="#symbols-function"><span class="secno">4</span> <span class="content">
Defining Anonymous Counter Styles: the <span class="css" data-link-type="maybe" title="symbols()">symbols()</span> function</span></a></li>
<li><a href="#extending-css2"><span class="secno">5</span> <span class="content">
Extending <span class="property" data-link-type="propdesc" title="list-style-type">list-style-type</span>, <span class="css" data-link-type="maybe" title="counter()">counter()</span>, and <span class="css" data-link-type="maybe" title="counters()">counters()</span></span></a></li>
<li><a href="#predefined-counters"><span class="secno">6</span> <span class="content">
Simple Predefined Counter Styles</span></a>
<ul class="toc">
<li><a href="#simple-numeric"><span class="secno">6.1</span> <span class="content">
Numeric: <span class="css" data-link-type="maybe" title="decimal">decimal</span>, <span class="css" data-link-type="maybe" title="decimal-leading-zero">decimal-leading-zero</span>, <span class="css" data-link-type="maybe" title="arabic-indic">arabic-indic</span>, <span class="css" data-link-type="maybe" title="armenian">armenian</span>, <span class="css" data-link-type="maybe" title="upper-armenian">upper-armenian</span>, <span class="css">lower-armenian</span>, <span class="css" data-link-type="maybe" title="bengali">bengali</span>, <span class="css" data-link-type="maybe" title="cambodian">cambodian</span>, <span class="css" data-link-type="maybe" title="khmer">khmer</span>, <span class="css" data-link-type="maybe" title="cjk-decimal">cjk-decimal</span>, <span class="css" data-link-type="maybe" title="devanagari">devanagari</span>, <span class="css" data-link-type="maybe" title="georgian">georgian</span>, <span class="css" data-link-type="maybe" title="gujarati">gujarati</span>, <span class="css" data-link-type="maybe" title="gurmukhi">gurmukhi</span>, <span class="css" data-link-type="maybe" title="hebrew">hebrew</span>, <span class="css" data-link-type="maybe" title="kannada">kannada</span>, <span class="css" data-link-type="maybe" title="lao">lao</span>, <span class="css" data-link-type="maybe" title="malayalam">malayalam</span>, <span class="css" data-link-type="maybe" title="mongolian">mongolian</span>, <span class="css" data-link-type="maybe" title="myanmar">myanmar</span>, <span class="css" data-link-type="maybe" title="oriya">oriya</span>, <span class="css" data-link-type="maybe" title="persian">persian</span>, <span class="css" data-link-type="maybe" title="lower-roman">lower-roman</span>, <span class="css" data-link-type="maybe" title="upper-roman">upper-roman</span>, <span class="css" data-link-type="maybe" title="tamil">tamil</span>, <span class="css" data-link-type="maybe" title="telugu">telugu</span>, <span class="css" data-link-type="maybe" title="thai">thai</span>, <span class="css" data-link-type="maybe" title="tibetan">tibetan</span></span></a></li>
<li><a href="#simple-alphabetic"><span class="secno">6.2</span> <span class="content">
Alphabetic: <span class="css" data-link-type="maybe" title="lower-alpha">lower-alpha</span>, <span class="css" data-link-type="maybe" title="lower-latin">lower-latin</span>, <span class="css" data-link-type="maybe" title="upper-alpha">upper-alpha</span>, <span class="css" data-link-type="maybe" title="upper-latin">upper-latin</span>, <span class="css" data-link-type="maybe" title="cjk-earthly-branch">cjk-earthly-branch</span>, <span class="css" data-link-type="maybe" title="cjk-heavenly-stem">cjk-heavenly-stem</span>, <span class="css" data-link-type="maybe" title="lower-greek">lower-greek</span>, <span class="css" data-link-type="maybe" title="hiragana">hiragana</span>, <span class="css" data-link-type="maybe" title="hiragana-iroha">hiragana-iroha</span>, <span class="css" data-link-type="maybe" title="katakana">katakana</span>, <span class="css" data-link-type="maybe" title="katakana-iroha">katakana-iroha</span></span></a></li>
<li><a href="#simple-symbolic"><span class="secno">6.3</span> <span class="content">
Symbolic: <span class="css" data-link-type="maybe" title="disc">disc</span>, <span class="css" data-link-type="maybe" title="circle">circle</span>, <span class="css" data-link-type="maybe" title="square">square</span>, <span class="css" data-link-type="maybe" title="disclosure-open">disclosure-open</span>, <span class="css" data-link-type="maybe" title="disclosure-closed">disclosure-closed</span></span></a></li>
</ul>
</li>
<li><a href="#complex-predefined-counters"><span class="secno">7& 9E70 lt;/span> <span class="content">
Complex Predefined Counter Styles</span></a>
<ul class="toc">
<li><a href="#complex-cjk"><span class="secno">7.1</span> <span class="content">
Longhand East Asian Counter Styles</span></a>
<ul class="toc">
<li><a href="#limited-japanese"><span class="secno">7.1.1</span> <span class="content">
Japanese: <span class="css" data-link-type="maybe" title="japanese-informal">japanese-informal</span> and <span class="css" data-link-type="maybe" title="japanese-formal">japanese-formal</span></span></a></li>
<li><a href="#limited-korean"><span class="secno">7.1.2</span> <span class="content">
Korean: <span class="css" data-link-type="maybe" title="korean-hangul-formal">korean-hangul-formal</span>, <span class="css" data-link-type="maybe" title="korean-hanja-informal">korean-hanja-informal</span>, and <span class="css" data-link-type="maybe" title="korean-hanja-formal">korean-hanja-formal</span></span></a></li>
<li><a href="#limited-chinese"><span class="secno">7.1.3</span> <span class="content">
Chinese: <span class="css" data-link-type="maybe" title="simp-chinese-informal">simp-chinese-informal</span>, <span class="css" data-link-type="maybe" title="simp-chinese-formal">simp-chinese-formal</span>, <span class="css" data-link-type="maybe" title="trad-chinese-informal">trad-chinese-informal</span>, and <span class="css" data-link-type="maybe" title="trad-chinese-formal">trad-chinese-formal</span></span></a></li>
</ul>
</li>
<li><a href="#ethiopic-numeric-counter-style"><span class="secno">7.2</span> <span class="content">
Ethiopic Numeric Counter Style: <span class="css" data-link-type="maybe" title="ethiopic-numeric">ethiopic-numeric</span></span></a></li>
</ul>
</li>
<li><a href="#additional-predefined"><span class="secno">8</span> <span class="content">
Additional Predefined Counter Styles</span></a></li>
<li><a href="#apis"><span class="secno">9</span> <span class="content">APIs</span></a>
<ul class="toc">
<li><a href="#extentions-to-cssrule-interface"><span class="secno">9.1</span> <span class="content">
Extensions to the <code>CSSRule</code> interface</span></a></li>
<li><a href="#the-csscounterstylerule-interface"><span class="secno">9.2</span> <span class="content">
The <code>CSSCounterStyleRule</code> interface</span></a></li>
</ul>
</li>
<li><a href="#ua-stylesheet"><span class="secno">10</span> <span class="content">
Sample style sheet for HTML</span></a></li>
<li><a href="#changes"><span class="secno"></span> <span class="content">
Changes since the August 2014 Last Call Working Draft</span></a></li>
<li><a href="#acknowledgments"><span class="secno"></span> <span class="content">
Acknowledgments</span></a></li>
<li><a href="#conformance"><span class="secno"></span> <span class="content">
Conformance</span></a>
<ul class="toc">
<li><a href="#conventions"><span class="secno"></span> <span class="content">
Document conventions</span></a></li>
<li><a href="#conformance-classes"><span class="secno"></span> <span class="content">
Conformance classes</span></a></li>
<li><a href="#partial"><span class="secno"></span> <span class="content">
Partial implementations</span></a></li>
<li><a href="#experimental"><span class="secno"></span> <span class="content">
Experimental implementations</span></a></li>
<li><a href="#testing"><span class="secno"></span> <span class="content">
Non-experimental implementations</span></a></li>
</ul>
</li>
<li><a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a></li>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a></li>
</ul>
</li>
<li><a href="#index"><span class="secno"></span> <span class="content">Index</span></a></li>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a>
<ul class="toc">
<li><a href="#counter-style-descriptor-table"><span class="secno"></span> <span class="content"><span data-link-type="at-rule">@counter-style</span> Descriptors</span></a></li>
</ul>
</li>
<li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a></li>
</ul></div>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">
Introduction</span><a class="self-link" href="#intro"></a></h2>
<p>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.</p>
<p>This module introduces the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> 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 <a class="property" data-link-type="propdesc" href="http://dev.w3.org/csswg/css-lists-3/#propdef-list-style-type">list-style-type</a> property
or in the <a class="css" data-link-type="maybe" href="http://dev.w3.org/csswg/css-lists-3/#funcdef-counter">counter()</a> and <a class="css" data-link-type="maybe" href="http://dev.w3.org/csswg/css-lists-3/#funcdef-counters">counters()</a> functions.
It also defines some additional predefined counter styles,
particularly ones which are common but complicated to represent with <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a>.</p>
<h2 class="heading settled" data-level="2" id="counter-styles"><span class="secno">2. </span><span class="content">
Counter Styles</span><a class="self-link" href="#counter-styles"></a></h2>
<p>A <dfn data-dfn-type="dfn" data-export="" id="counter-style">counter style<a class="self-link" href="#counter-style"></a></dfn> defines how to convert a counter value into a string.
Counter styles are composed of:</p>
<ul>
<li>
a name,
to identify the style
</li>
<li>
an algorithm,
which transforms integer counter values into a basic string representation
</li>
<li>
a negative sign,
which is prepended or appended to the representation of a negative counter value.
</li>
<li>
a prefix,
to prepend to the representation
</li>
<li>
a suffix
to append to the representation
</li>
<li>
a range,
which limits the values that a counter style handles
</li>
<li>
a spoken form,
which describes how to read out the counter style in a speech synthesizer
</li>
<li>
and a fallback style,
to render the representation with when the counter value is outside the counter style’s range
or the counter style otherwise can’t render the counter value
</li>
</ul>
<p>When asked to <dfn data-dfn-type="dfn" data-export="" id="generate-a-counter" title="generate a counter|generate a counter representation">generate a counter representation<a class="self-link" href="#generate-a-counter"></a></dfn>
using a particular counter style for a particular counter value,
follow these steps:</p>
<ol>
<li>
If the counter style is unknown,
exit this algorithm and instead <i>generate a counter representation</i>
using the <a class="css" data-link-type="maybe" href="#decimal">decimal</a> style and the same counter value.
</li>
<li>
If the counter value is outside the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-range">range</a> of the counter style,
exit this algorithm and instead <i>generate a counter representation</i>
using the counter style’s fallback style and the same counter value.
</li>
<li>
Using the counter value and the counter algorithm for the counter style,
generate an <dfn data-dfn-type="dfn" data-noexport="" id="initial-representation-for-the-counter-value">initial representation for the counter value<a class="self-link" href="#initial-representation-for-the-counter-value"></a></dfn>.
If the counter value is negative
and the counter style <i>uses a negative sign</i>,
instead generate an initial representation using the absolute value of the counter value.
</li>
<li>
Prepend symbols to the representation as specified in the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-pad">pad</a> descriptor.
</li>
<li>
If the counter value is negative
and the counter style <i>uses a negative sign</i>,
wrap the representation in the counter style’s negative sign
as specified in the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-negative">negative</a> descriptor.
</li>
<li>
Return the representation.
</li>
</ol>
<p class="note" role="note">Note: 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 <a class="property" data-link-type="propdesc" href="http://dev.w3.org/csswg/css-content-3/#propdef-content">content</a> property
for the <a class="css" data-link-type="maybe" href="http://dev.w3.org/csswg/css-lists-3/#selectordef-marker">::marker</a> 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.</p>
<p>Some values of <a class="property" data-link-type="propdesc" href="#descdef-counter-style-system">system</a> (<a class="css" data-link-type="maybe" href="#valdef-system-symbolic">symbolic</a>, <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-additive">additive</a>)
and some descriptors (<a class="property" data-link-type="propdesc" href="#descdef-counter-style-pad">pad</a>)
can generate representations with size linear to an author-supplied number.
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 60 Unicode codepoints long,
but they may choose to instead use the fallback style for representations that would be longer than 60 codepoints.</p>
<h2 class="heading settled" data-level="3" id="the-counter-style-rule"><span class="secno">3. </span><span class="content">
Defining Custom Counter Styles: the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule</span><a class="self-link" href="#the-counter-style-rule"></a></h2>
<p>The <dfn class="css" data-dfn-type="at-rule" data-export="" id="at-ruledef-counter-style">@counter-style<a class="self-link" href="#at-ruledef-counter-style"></a></dfn> rule allows authors to define a custom <i>counter style</i>.
The components of a <i>counter style</i> are specified by descriptors in the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule.
The algorithm is specified implicitly by a combination of the <span class="css">system</span>, <span class="css">symbols</span>, and <span class="css">additive-symbols</span> properties.</p>
<p>The general form of an <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is:</p>
<pre>@counter-style <a class="production" data-link-type="type" href="#typedef-counter-style-name">&lt;counter-style-name></a> { <a class="production" data-link-type="type" href="http://dev.w3.org/csswg/css-syntax-3/#typedef-declaration-list">&lt;declaration-list></a> }</pre>
<p>where <dfn class="css" data-dfn-type="type" data-export="" id="typedef-counter-style-name">&lt;counter-style-name><a class="self-link" href="#typedef-counter-style-name"></a></dfn> is a <a class="production css" data-link-type="type" href="http://dev.w3.org/csswg/css-values-3/#identifier-value">&lt;custom-ident></a>.</p>
<p>If a counter style’s name is an <a data-link-type="dfn" href="http://dev.w3.org/csswg/css-syntax-3/#ascii-case_insensitive">ASCII case-insensitive</a> match for "decimal" or "none",
the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.</p>
<p class="note" role="note">Note: Note that <a class="production css" data-link-type="type" href="http://dev.w3.org/csswg/css-values-3/#identifier-value">&lt;custom-ident></a> also automatically excludes the <a data-link-spec="css-values" data-link-type="dfn" href="http://dev.w3.org/csswg/css-values-3/#css-wide-keywords">CSS-wide keywords</a>.
In addition, some names, like <a class="css" data-link-type="maybe" href="http://dev.w3.org/csswg/css-lists-3/#valuedef-inside">inside</a>,
are valid as counter style names,
but conflict with the existing values of properties like <a class="property" data-link-type="propdesc" href="http://dev.w3.org/csswg/css-lists-3/#propdef-list-style">list-style</a>,
and so won’t be usable there.</p>
<p>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 <a class="property" data-link-type="propdesc" href="http://dev.w3.org/csswg/css-lists-3/#propdef-list-style">list-style</a> set of properties,
in the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule,
and in the <a class="css" data-link-type="maybe" href="http://dev.w3.org/csswg/css-lists-3/#funcdef-counter">counter()</a> functions.</p>
<p>Each <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> 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 <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> 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 <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule,
only the last specified value is used;
all prior values for that descriptor must be ignored.</p>
<p>Defining a <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> makes it available to the entire document in which it is included.
If multiple <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rules are defined with the same name,
only one wins,
according to standard cascade rules.
<a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rules cascade "atomically":
if one replaces another of the same name,
it replaces it <em>entirely</em>,
rather than just replacing the specific descriptors it specifies.</p>
<p class="note" role="note">Note: Note that even the predefined counter styles can be overridden;
the UA stylesheet occurs before any other stylesheets,
so the predefined ones always lose in the cascade.</p>
<p>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,
or whose value does not match the grammars given here or in a future version of this specification,
must be ignored in their entirety;
they do not make the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule invalid.</p>
<h3 class="heading settled" data-level="3.1" id="counter-style-system"><span class="secno">3.1. </span><span class="content">
Counter algorithms: the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-system">system</a> descriptor</span><a class="self-link" href="#counter-style-system"></a></h3>
<table class="definition descdef" data-dfn-for="@counter-style">
<tbody>
<tr>
<th>Name:</th>
<td><dfn class="css" data-dfn-for="@counter-style" data-dfn-type="descriptor" data-export="" id="descdef-counter-style-system">system<a class="self-link" href="#descdef-counter-style-system"></a></dfn></td>
</tr>
<tr>
<th>For:</th>
<td><a class="css" data-link-type="at-rule" href="#at-ruledef-counter-style">@counter-style</a></td>
</tr>
<tr>
<th>Value:</th>
<td class="prod">cyclic <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> numeric <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> alphabetic <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> symbolic <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> additive <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> <span class="nobr">[fixed <a class="production css" data-link-type="type" href="http://dev.w3.org/csswg/css-syntax-3/#typedef-integer">&lt;integer></a><a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#mult-opt">?</a>]</span> <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> <span class="nobr">[ extends <a class="production css" data-link-type="type" href="#typedef-counter-style-name">&lt;counter-style-name></a> ]</span></td>
</tr>
<tr>
<th>Initial:</th>
<td>symbolic</td>
</tr>
</tbody></table>
<p>The <a class="property" data-link-type="propdesc" href="#descdef-counter-style-system">system</a> descriptor specifies which algorithm will be used to construct
the counter’s representation based on the counter value. For example,
<a class="css" data-link-type="maybe" href="#valdef-counter-style-system-cyclic">cyclic</a> counter styles just cycle through their symbols repeatedly,
while <a class="css" data-link-for="system" data-link-type="value" href="#valdef-counter-style-system-numeric">numeric</a> counter styles interpret their symbols as digits and
build their representation accordingly. The systems are defined as follows:</p>
<h4 class="heading settled" data-level="3.1.1" id="cyclic-system"><span class="secno">3.1.1. </span><span class="content">
Cycling Symbols: the <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-cyclic">cyclic</a> system</span><a class="self-link" href="#cyclic-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="@counter-style/system" data-dfn-type="value" data-export="" id="valdef-counter-style-system-cyclic">cyclic<a class="self-link" href="#valdef-counter-style-system-cyclic"></a></dfn> 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 <i>counter symbol</i>),
or for cycling through multiple symbols.
The first <i>counter symbol</i> is used as the representation of the value 1,
the second <i>counter symbol</i> (if it exists) is used as the representation of the value 2, etc.</p>
<p>If the system is <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-cyclic">cyclic</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-symbols">symbols</a> descriptor must contain at least one <i>counter symbol</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is defined over all counter values.</p>
<div class="example">
A "triangle bullet" counter style can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="triangle">triangle<a class="self-link" href="#triangle"></a></dfn> {
system: cyclic;
symbols: ‣;
suffix: " ";
}
</pre>
<p>It will then produce lists that look like:</p>
<pre>‣ One
‣ Two
‣ Three
</pre>
</div>
<p>If there are <var>N</var> <i>counter symbols</i>
and a representation is being constructed for the integer <var>value</var>,
the representation is the <i>counter symbol</i>
at index ( (<var>value</var>-1) mod <var>N</var>)
of the list of <i>counter symbols</i> (0-indexed).</p>
< 8096 /div>
<h4 class="heading settled" data-level="3.1.2" id="fixed-system"><span class="secno">3.1.2. </span><span class="content">
Exhaustible Symbols: the <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-fixed">fixed</a> system</span><a class="self-link" href="#fixed-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="@counter-style/system" data-dfn-type="value" data-export="" id="valdef-counter-style-system-fixed">fixed<a class="self-link" href="#valdef-counter-style-system-fixed"></a></dfn> 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.</p>
<p>If the system is <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-fixed">fixed</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-symbols">symbols</a> descriptor must contain at least one <i>counter symbol</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is defined over counter values in a finite range,
starting with the <i>first symbol value</i> and having a length equal to the length of the list of <i>counter symbols</i>.</p>
<p>When this system is specified,
it may optionally have an integer provided after it,
which sets the <dfn data-dfn-type="dfn" data-export="" id="first-symbol-value">first symbol value<a class="self-link" href="#first-symbol-value"></a></dfn>.
If it is omitted, the <i>first symbol value</i> is 1.</p>
<div class="example">
A "box-corner" counter style can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="box_corner">box-corner<a class="self-link" href="#box_corner"></a></dfn> {
system: fixed;
symbols: ◰ ◳ ◲ ◱;
suffix: ': ';
}
</pre>
<p>It will then produce lists that look like:</p>
<pre>◰: One
◳: Two
◲: Three
◱: Four
5: Five
6: Six
</pre>
</div>
<p>The first <i>counter symbol</i> is the representation for the <i>first symbol value</i>,
and subsequent counter values are represented by subsequent <i>counter symbols</i>.
Once the list of <i>counter symbols</i> is exhausted,
further values cannot be represented by this counter style,
and must instead be represented by the fallback counter style.</p>
<h4 class="heading settled" data-level="3.1.3" id="symbolic-system"><span class="secno">3.1.3. </span><span class="content">
Repeating Symbols: the <a class="css" data-link-type="maybe" href="#valdef-system-symbolic">symbolic</a> system</span><a class="self-link" href="#symbolic-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="system" data-dfn-type="value" data-export="" id="valdef-system-symbolic">symbolic<a class="self-link" href="#valdef-system-symbolic"></a></dfn> 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 <a class="css" data-link-for="system" data-link-type="value" href="#valdef-counter-style-system-alphabetic">alphabetic</a> system presents.</p>
<p>If the system is <a class="css" data-link-type="maybe" href="#valdef-system-symbolic">symbolic</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-symbols">symbols</a> descriptor must contain at least one <i>counter symbol</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is defined only over strictly positive counter values.</p>
<div class="example">
An "footnote" counter style can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="footnote">footnote<a class="self-link" href="#footnote"></a></dfn> {
system: symbolic;
symbols: '*' ⁑ † ‡;
suffix: " ";
}
</pre>
<p>It will then produce lists that look like:</p>
<pre>* One
⁑ Two
† Three
‡ Four
** Five
⁑⁑ Six
</pre>
</div>
<div class="example">
Some style guides mandate a list numbering that looks similar to <a class="css" data-link-type="maybe" href="#upper-alpha">upper-alpha</a>,
but repeats differently after the first 26 values,
instead going "AA", "BB", "CC", etc.
This can be achieved with the symbolic system:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="upper_alpha_legal">upper-alpha-legal<a class="self-link" href="#upper_alpha_legal"></a></dfn> {
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;
}
</pre>
<p>This style is identical to <a class="css" data-link-type="maybe" href="#upper-alpha">upper-alpha</a> through the first 27 values,
but they diverge after that, with <a class="css" data-link-type="maybe" href="#upper-alpha">upper-alpha</a> going "AB", "AC", "AD", etc.
Starting at the 53rd value, <a class="css" data-link-type="maybe" href="#upper-alpha">upper-alpha</a> goes "BA", "BB", "BC", etc.,
while this style jumps into triple digits with "AAA", "BBB", "CCC", etc.</p>
</div>
<p>To construct the representation, run the following algorithm:</p>
<p>Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value,
<var>S</var> initially be the empty string,
and <var>symbol(n)</var> be the nth <i>counter symbol</i> in the list of <i>counter symbols</i> (0-indexed).</p>
<ol>
<li>Let the <var>chosen symbol</var> be <code class="inline">symbol( (<var>value</var> - 1) mod <var>N</var>)</code>.
</li>
<li>Let the <var>representation length</var> be <code class="inline">ceil( <var>value</var> / <var>N</var> )</code>.
</li>
<li>Append the <var>chosen symbol</var> to <var>S</var> a number of times equal to the <var>representation length</var>.
</li>
</ol>
<p>Finally, return <var>S</var>.</p>
<h4 class="heading settled" data-level="3.1.4" id="alphabetic-system"><span class="secno">3.1.4. </span><span class="content">
Bijective Numerals: the <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-alphabetic">alphabetic</a> system</span><a class="self-link" href="#alphabetic-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="@counter-style/system" data-dfn-type="value" data-export="" id="valdef-counter-style-system-alphabetic">alphabetic<a class="self-link" href="#valdef-counter-style-system-alphabetic"></a></dfn> counter system interprets the list of <i>counter symbols</i> as digits to an <em>alphabetic</em> numbering system,
similar to the default <a class="css" data-link-type="maybe" href="#lower-alpha">lower-alpha</a> 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 <i>counter symbol</i> in the list is interpreted as the digit 1,
the second as the digit 2,
and so on.</p>
<p>If the system is <a class="css" data-link-for="system" data-link-type="value" href="#valdef-counter-style-system-alphabetic">alphabetic</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-symbols">symbols</a> descriptor must contain at least two <i>counter symbols</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is defined only over strictly positive counter values.</p>
<div class="example">
A counter style using go stones can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="go">go<a class="self-link" href="#go"></a></dfn> {
system: alphabetic;
symbols: url(white.svg) url(black.svg);
suffix: " ";
}
</pre>
<p>It will then produce lists that look like:</p>
<div class="alphabetic-example">
<span><img alt="" src="images/white.svg"></span> One<br>
<span><img alt="" src="images/black.svg"></span> Two<br>
<span><img alt="" src="images/white.svg"><img alt="" src="images/white.svg"></span> Three<br>
<span><img alt="" src="images/white.svg"><img alt="" src="images/black.svg"></span> Four<br>
<span><img alt="" src="images/black.svg"><img alt="" src="images/white.svg"></span> Five<br>
<span><img alt="" src="images/black.svg"><img alt="" src="images/black.svg"></span> Six<br>
<span><img alt="" src="images/white.svg"><img alt="" src="images/white.svg"><img alt="" src="images/white.svg"></span> Seven
</div>
<p class="note" role="note">Note: This example requires support for SVG images to display correctly.</p>
</div>
<p>If there are <var>N</var> <i>counter symbols</i>,
the representation is a base <var>N</var> alphabetic number using the <i>counter symbols</i> as digits.
To construct the representation, run the following algorithm:</p>
<p>Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value,
<var>S</var> initially be the empty string,
and <var>symbol(n)</var> be the nth <i>counter symbol</i> in the list of <i>counter symbols</i> (0-indexed).</p>
<p>While <var>value</var> is not equal to 0:</p>
<ol>
<li>Set <var>value</var> to <code><var>value</var> - 1</code>.
</li>
<li>Prepend <var>symbol( <var>value</var> mod <var>N</var> )</var>
to <var>S</var>.
</li>
<li>Set <var>value</var> to <code>floor( <var>value</var> / <var>N</var> )</code>.
</li>
</ol>
<p>Finally, return <var>S</var>.</p>
<h4 class="heading settled" data-level="3.1.5" id="numeric-system"><span class="secno">3.1.5. </span><span class="content">
Positional Numerals: the <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-numeric">numeric</a> system</span><a class="self-link" href="#numeric-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="@counter-style/system" data-dfn-type="value" data-export="" id="valdef-counter-style-system-numeric">numeric<a class="self-link" href="#valdef-counter-style-system-numeric"></a></dfn> counter system interprets the list of <i>counter symbols</i>
as digits to a "place-value" numbering system,
similar to the default <a class="css" data-link-type="maybe" href="#decimal">decimal</a> counter style.
The first <i>counter symbol</i> in the list is interpreted as the digit 0,
the second as the digit 1,
and so on.</p>
<p>If the system is <a class="css" data-link-for="system" data-link-type="value" href="#valdef-counter-style-system-numeric">numeric</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-symbols">symbols</a> descriptor must contain at least two <i>counter symbols</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is defined over all counter values.</p>
<div class="example">
A "trinary" counter style can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="trinary">trinary<a class="self-link" href="#trinary"></a></dfn> {
system: numeric;
symbols: '0' '1' '2';
}
</pre>
<p>It will then produce lists that look like:</p>
<pre>1. One
2. Two
10. Three
11. Four
12. Five
20. Six
</pre>
</div>
<p>If there are <var>N</var> <i>counter symbols</i>,
the representation is a base <var>N</var> number using the <i>counter symbols</i> as digits.
To construct the representation, run the following algorithm:</p>
<p>Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value,
<var>S</var> initially be the empty string,
and <var>symbol(n)</var> be the nth <i>counter symbol</i> in the list of <i>counter symbols</i> (0-indexed).</p>
<ol>
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to
<var>S</var> and return <var>S</var>.
</li>
<li>While <var>value</var> is not equal to 0:
<ol>
<li>Prepend <var>symbol( <var>value</var> mod <var>N</var> )</var>
to <var>S</var>.
</li>
<li>Set <var>value</var> to <code>floor( <var>value</var> / <var>N</var> )</code>.
</li>
</ol>
</li>
<li>Return <var>S</var>.
</li>
</ol>
<h4 class="heading settled" data-level="3.1.6" id="additive-system"><span class="secno">3.1.6. </span><span class="content">
Accumulating Numerals: the <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-additive">additive</a> system</span><a class="self-link" href="#additive-system"></a></h4>
<p>The <dfn class="css" data-dfn-for="@counter-style/system" data-dfn-type="value" data-export="" id="valdef-counter-style-system-additive">additive<a class="self-link" href="#valdef-counter-style-system-additive"></a></dfn> 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.</p>
<p>If the system is <a class="css" data-link-type="maybe" href="#valdef-counter-style-system-additive">additive</a>,
the <a class="property" data-link-type="propdesc" href="#descdef-counter-style-additive-symbols">additive-symbols</a> descriptor must contain at least one <i>additive tuple</i>,
or else the <a class="css" data-link-type="maybe" href="#at-ruledef-counter-style">@counter-style</a> rule is invalid.
This system is nominally defined over all counter values
(see algorithm, below, for exact details).</p>
<div class="example">
A "dice" counter style can be defined as:
<pre>@counter-style <dfn data-dfn-type="dfn" data-noexport="" id="dice">dice<a class="self-link" href="#dice"></a></dfn> {
system: additive;
additive-symbols: 6 ⚅, 5 ⚄, 4 ⚃, 3 ⚂, 2 ⚁, 1 ⚀;
suffix: " ";
}
</pre>
<p>It will then produce lists that look like:</p>
<pre> ⚀ One
⚁ Two
⚂ Three
...
⚅⚄ Eleven
⚅⚅ Twelve
⚅⚅⚀ Thirteen
</pre>
</div>
<p>To construct the representation, run this algorithm:</p>
<p>Let <var>value</var> initially be the counter value,
<var>S</var> initially be the empty string,
and <var>symbol list</var> initially be the list of <i>additive tuples</i>.</p>
<ol>
<li>If <var>value</var> is initially 0, and there is an <i>additive tuple</i> with a weight of 0, append that tuple’s <i>counter symbol</i> to S and return S.
</li>
<li>While <var>value</var> is greater than 0 and there are elements left in the <var>symbol list</var>: