XML technologies / CSS / CSS Cookbook / Lists / Changing a list’s formatting

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

Change a list’s default presentation to use a different bullet or special numbering, for example, as shown in the following figure.

List markers: lowercase Roman numerals

Figure: This list uses lowercase Roman numerals as markers.

Solution

Use the property list-style-type to customize list bullets or counters:

li {
 list-style-type: lower-roman;
}

Discussion

The CSS 2.1 specification defines several marker styles (see the following table). Browsers generally use different markers for different nesting levels. Instead, you can use list-style-type to define your own markers for nested lists.

Table: Different marker styles.

Style/value

Description

Browser support

square

Usually a filled square; the exact appearance is not further defined.

All major browsers

disc

Usually a filled circle; the exact appearance is not further defined.

All major browsers

circle

Usually an unfilled circle; the exact appearance is not further defined.

All major browsers

decimal

Sequential numbers starting at 1, followed by 2, 3, 4 and so on.

All major browsers

decimal-leading-zero

Sequential numbers with one or more leading zeros, starting at 01, followed by 02, 03, 04 and so on. The number of leading zeros may correspond to the number of digits used in the list. In a list of 5876 items, the first number would then be 0001.

All major browsers

lower-roman

Starts with a sequence of lowercase Roman numerals.

All major browsers

upper-roman

Starts with a sequence of uppercase Roman numerals.

All major browsers

lower-alpha

Starts with a sequence of lowercase ASCII letters.

All major browsers

upper-alpha

Starts with a sequence of uppercase ASCII letters.

All major browsers

lower-latin

Starts with a sequence of lowercase ASCII letters.

All major browsers

upper-latin

Starts with a sequence of uppercase ASCII letters.

All major browsers

lower-greek

Starts with classical Greek letters: alpha, then beta, gamma and so on.

Safari, Mozilla, Netscape 6+

hebrew

Starts numbering with traditional Hebrew letters.

Safari, Mozilla, Netscape 6+

hiragana

Starts numbering with the classical Japanese Hiragana system.

Mozilla, Netscape 6+

katakana

Starts numbering with the classical Japanese Katakana system.

Mozilla, Netscape 6+

hiragana-iroha

Starts numbering with the classical Japanese Hiragana-Iroha system.

Mozilla, Netscape 6+

katakana-iroha

Starts numbering with the classical Japanese Katakana-Iroha system.

Mozilla, Netscape 6+

none

No marker is displayed.

All major browsers

See also

The recipe Using large images as list bullets on using custom images as bullets, and chapter 12 of CSS – Das umfassende Handbuch by Eric A. Meyer (O’Reilly).

  

 

 

 

back to top