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

list-style-type

· 52CE 我爱测

CSS 属性 `list-style-type` 可以设置列表元素的 marker(比如圆点、符号、或者自定义计数器样式)。

CSS 属性 list-style-type 可以设置列表元素的 marker(比如圆点、符号、或者自定义计数器样式)。

CSS Demo: list-style-type

list-style-type: space-counter;
list-style-type: disc;
list-style-type: circle;
list-style-type: "\1F44D";
<section class="default-example" id="default-example">
  <div>
    <p>NASA Notable Missions</p>
    <ul class="transition-all unhighlighted" id="example-element">
      <li>Apollo</li>
      <li>Hubble</li>
      <li>Chandra</li>
      <li>Cassini-Huygens</li>
    </ul>
  </div>
  <hr />
  <div class="note">
    <p>
      <code>space-counter</code> is defined with
      <a
        href="//developer.mozilla.org/docs/Web/CSS/@counter-style"
        target="_parent"
        ><code>@counter-style</code></a
      >
    </p>
  </div>
</section>
.default-example {
  font-size: 1.2rem;
}

#example-element {
  width: 100%;
  background: #be094b;
  color: white;
}

section {
  text-align: left;
  flex-direction: column;
}

hr {
  width: 50%;
  color: lightgray;
  margin: 0.5em;
}

.note {
  font-size: 0.8rem;
}

.note a {
  color: #009e5f;
}

@counter-style space-counter {
  symbols: "\1F680" "\1F6F8" "\1F6F0" "\1F52D";
  suffix: " ";
}

The color of the marker will be the same as the computed color of the element it applies to.

只有几个元素 (li 和 summary) 的默认值为 display: list-item。但是, list-style-type 属性可以应用在任何 display 的值为 list-item 的元素上。此外,由于这个属性是可继承的,它可以设置在父元素上 (通常是 ol 或 ul) 以便应用于所有子元素 (li)。

语法

/* Partial list of types */
list-style-type: disc;
list-style-type: circle;
list-style-type: square;
list-style-type: decimal;
list-style-type: georgian;
list-style-type: trad-chinese-informal;
list-style-type: kannada;

/* <string> value */
list-style-type: "-";

/* Identifier matching an @counter-style rule */
list-style-type: custom-counter-style;

/* Keyword value */
list-style-type: none;

/* Global values */
list-style-type: inherit;
list-style-type: initial;
list-style-type: unset;

list-style-type 的属性值可以是以下任意一项:

取值

  • custom-ident
    • : A identifier matching the value of a @counter-style or one of the predefined styles:
  • symbols()
    • : Defines an anonymous style of the list.
  • <string>
    • : The specified string will be used as the item's marker.
  • none
    • : 不显示列表项的标记。
  • disc
    • : 实心圆点 (默认值)
  • circle
    • : 空心圆点
  • square
    • : 实心方块
  • decimal
    • : 十进制阿拉伯数字
  • cjk-decimal
    • : 中日韩十进制数
  • decimal-leading-zero
    • : Decimal numbers, padded by initial zeros.
  • lower-roman
    • : Lowercase roman numerals
  • upper-roman
    • : Uppercase roman numerals
  • lower-greek
    • : Lowercase classical Greek
      • alpha, beta, gamma…
  • lower-alpha, lower-latin
    • : Lowercase ASCII letters
  • upper-alpha, upper-latin
    • : Uppercase ASCII letters
  • armenian
    • : Traditional Armenian numbering
  • georgian
    • : Traditional Georgian numbering
  • hebrew
    • : Traditional Hebrew numbering
  • ethiopic-numeric
  • hiragana
    • : Dictionary-order hiragana lettering.
  • katakana
    • : Dictionary-order katakana lettering
  • hiragana-iroha
    • : Iroha is the old japanese ordering of syllabs.
  • katakana-iroha
    • : Iroha is the old japanese ordering of syllabs.
  • japanese-informal
    • : Japanese informal numbering
  • japanese-formal
    • : Japanese formal numbering to be used in legal or financial document. The kanjis are designed so that they can't be modified to look like another correct one
  • korean-hangul-formal
    • : Korean hangul numbering.
  • korean-hanja-informal
    • : Korean hanja numbering.
  • korean-hanja-formal
    • : Formal Korean Han numberging.
  • simp-chinese-informal
    • : Simplified Chinese informal numberging.
  • cjk-ideographic
    • : Identical to simp-chinese-informal
  • simp-chinese-formal
    • : Simplified Chinese formal numberging.
  • trad-chinese-informal
    • : Traditional Chinese informal numberging.
  • trad-chinese-formal
    • : Traditional Chinese formal numberging.

非标准扩展

Extended set of values provided by Mozilla (Firefox), Blink (Chrome and Opera) and WebKit (Safari) to support list types in other languages. See the compatibility table to check which browsers supports which extension.

  • arabic-indic、-moz-arabic-indic
  • bengali、-moz-bengali
  • cjk-earthly-branch、-moz-cjk-earthly-branch
  • cjk-heavenly-stem、-moz-cjk-heavenly-stem
  • devanagari、-moz-devanagari
  • -moz-ethiopic-halehame
  • -moz-ethiopic-halehame-am
  • ethiopic-halehame-ti-er、-moz-ethiopic-halehame-ti-er
  • ethiopic-halehame-ti-et、-moz-ethiopic-halehame-ti-et
  • gujarati、-moz-gujarati
  • gurmukhi、-moz-gurmukhi
  • hangul、-moz-hangul
  • hangul-consonant、-moz-hangul-consonant
  • kannada、-moz-kannada
  • khmer、-moz-khmer
  • lao、-moz-lao
  • malayalam、-moz-malayalam
  • myanmar、-moz-myanmar
  • oriya、-moz-oriya
  • persian、-moz-persian
  • -moz-tamil
  • telugu、-moz-telugu
  • thai、-moz-thai
  • urdu、-moz-urdu

Formal syntax

例子

CSS

ol.normal {
  list-style-type: upper-alpha;
}

/* or use the shortcut "list-style": */
ol.shortcut {
  list-style: upper-alpha;
}

HTML

<ol class="normal">
  List 1
  <li>Hello</li>
  <li>World</li>
  <li>What's up?</li>
</ol>

<ol class="shortcut">
  List 2
  <li>Looks</li>
  <li>Like</li>
  <li>The</li>
  <li>Same</li>
</ol>

Result

例子

Accessibility concerns

The VoiceOver screen reader has an issue where unordered lists with a list-style-typevalue of none applied to them will not be announced as a list. To address this, add a zero-width space as pseudo content before each list item to ensure the list is announced properly. This ensures the design is unaffected by the bug fix and that list items are not improperly described.

ul {
  list-style: none;
}

ul li::before {
  content: "\200B";
}

注释

  • Some types require a suitable font installed to display as expected.
  • The cjk-ideographic is identical to trad-chinese-informal; it exists for legacy reasons.

规范

浏览器兼容性

参见

  • list-style, list-style-image, list-style-position

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

资料来源与适用范围

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

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

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