大网数据广告活动
Web 标准与前端开发

`fallback` CSS at-rule descriptor

· 52CE 我爱测

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.

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

/* 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 @counter-style/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 @counter-style/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

Formal syntax

Examples

Specifying a fallback counter style

HTML

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

CSS

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

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

Result

Specifying_a_fallback_counter_style

Specifications

Browser compatibility

See also

  • Other @counter-style descriptors: @counter-style/system, @counter-style/symbols, @counter-style/additive-symbols, @counter-style/negative, @counter-style/prefix, @counter-style/suffix, @counter-style/range, @counter-style/pad, and @counter-style/speak-as
  • list-style, list-style-image, list-style-position
  • symbols(): the functional notation for creating anonymous counter styles

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。