This example renders a list using Roman numerals. Notice that a range
is specified. This is because the representation will produce correct Roman numerals only until the counter value of 3999
. Once outside of the range, the rest of the counter representations will be based on the decimal
style, which is the fall back. If you need to represent counter values as Roman numerals, you could use either one of the predefined counter styles, upper-roman
or lower-roman
, rather than recreating the rule yourself.
HTML
We use the start
attribute on the <ol>
element to demonstrate that counting doesn't need to start at 1
. Additionally, we use the value
attribute on the fifth <li>
element to demonstrate that the counters you define using @counter-style
behave just like native counters.
<ol start="48">
<li>48</li>
<li>49</li>
<li>50</li>
<li>51</li>
<li value="109">109</li>
<li>110</li>
<ol></ol>
</ol>
CSS
@counter-style uppercase-roman {
system: additive;
range: 1 3999;
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;
}
ol {
list-style: uppercase-roman;
padding-left: 5em;
}
Result