fallback CSS at-rule descriptor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2023.

The fallback descriptor of the @counter-style at-rule can be used to specify a counter style to fall back to if the counter style being defined cannot create a marker representation for a particular counter value.

Syntax

css
/* Keyword values */
fallback: lower-alpha;
fallback: custom-gangnam-style;

Value

The descriptor takes a single <counter-style-name> as its value:

<counter-style-name>

Provides the name of the counter style to be used as the fallback, which is either the case-sensitive <custom-ident> of a custom CSS counter style (without quotes) or a case-insensitive list-style-type property value such as decimal, disc, and so on.

If omitted, the counter fallback defaults to decimal.

Description

The counter style provided as the value of the fallback descriptor is used when a range descriptor is specified for a counter style; the fallback style is used to represent all the values that fall outside the range. The fallback style is also used when the fixed system is used and there are not enough symbols to cover all the list items; the fallback style is used to represent all the values beyond the scope of the fixed system. In both these cases, and any other time the defined counter cannot create a specific counter value, the fallback style is used.

If the specified fallback style is also unable to construct a representation, then the fallback value of that fallback counter is used. If that fallback style's fallback is also unable to construct a representation, then that fallback's fallback is used. This falling back continues until a fallback is found that can construct the counter-representation. If no fallback fallback value is able to construct a representation―if a fallback style doesn't have a fallback value set, or if a fallback value is not specified or invalid―the fallback defaults to decimal.

Formal definition

Related at-rule@counter-style
Initial valuedecimal
Computed valueas specified

Formal syntax

fallback = 
<counter-style-name>

<counter-style-name> =
<custom-ident>

Examples

Specifying a fallback counter style

HTML

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

CSS

css
@counter-style fallback-example {
  system: fixed;
  symbols: "\24B6" "\24B7" "\24B8";
  fallback: upper-alpha;
}

.list {
  list-style: fallback-example;
}

Result

Specifications

Specification
CSS Counter Styles Level 3
# counter-style-fallback

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fallback
Chrome – Full support
Chrome 91 (Release date: 2021-05-25)
footnote Full support
Edge – Full support
Edge 91 (Release date: 2021-05-27)
footnote Full support
Firefox – Full support
Firefox 33 (Release date: 2014-10-14)
footnote Full support
Opera – Full support
Opera 77 (Release date: 2021-06-09)
footnote Full support
Safari – Full support
Safari 17 (Release date: 2023-09-18)
footnote Full support
Chrome Android – Full support
Chrome Android 91 (Release date: 2021-05-25)
footnote Full support
Firefox for Android – Full support
Firefox for Android 33 (Release date: 2014-10-14)
footnote Full support
Opera Android – Full support
Opera Android 64 (Release date: 2021-05-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17 (Release date: 2023-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 16 (Release date: 2021-11-25)
footnote Full support
WebView Android – Full support
WebView Android 91 (Release date: 2021-05-25)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17 (Release date: 2023-09-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also