CSS - fallback

The fallback descriptor can be used to specify a counter style to fall back to if the current counter style cannot create a marker representation for a particular counter value. If the specified fallback style is also unable to construct a representation, then its fallback style will be used. If a valid fallback style is not specified, it defaults to decimal. A few scenarios where fallback style will be used are:

Example

 

HTML Content

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

CSS Content

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

Result

Syntax  

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

Formal syntax

CSS
<a href="css/@counter-style/fallback#counter-style-name"><counter-style-name></a><p>where <br><code><counter-style-name> = <custom-ident></code></p>

Description  

The fallback descriptor can be used to specify a counter style to fall back to if the current counter style cannot create a marker representation for a particular counter value. If the specified fallback style is also unable to construct a representation, then its fallback style will be used. If a valid fallback style is not specified, it defaults to decimal. A few scenarios where fallback style will be used are:

  • When the range descriptor is specified for a counter style, the fallback style will be used to represent values that fall outside the range.
  • When the fixed system is used and there are not enough symbols to cover all the list items, the fallback style will be used for the rest of the list items.

Related at-rule@counter-style
Initial valuedecimal
Mediaall
Computed valueas specified
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support 33 (33) No support No support No support
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support 33 (33) No support No support No support

See Also  

Specifications  

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

License

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

@counter-style CSS CSS Counter Styles CSS Descriptor Reference