liveBook · Manning

Counter-style at-rule

As explained in Tiny CSS Projects

The CSS @counter-style at-rule defines a custom counter style, including its symbols, numbering system, and formatting.

The @counter-style at-rule defines a reusable custom list style. It names the counter, describes its behavior, and lets a list replace default bullets with a chosen symbol. section 4.2

Define the custom counter with three declarations:

  • symbols selects the symbol or symbols displayed for list items. section 4.2
  • system controls how the defined symbols are used; cyclic repeats the available symbol. section 4.2.4
  • suffix adds the content after each counter, such as a space. section 4.2.4
  • Apply the named style with list-style on the target list. section 4.2.4

Hot-beverage list markers

A custom style named emoji uses the hot-beverage symbol, repeats it cyclically, and applies it to an article's unordered list. section 4.2 section 4.2.4

Listing 4.8 Styling the list
@counter-style emoji {     #1
  symbols: "\2615";        #2
  system: cyclic;
  suffix: " ";
}
 
article ul {
  list-style: emoji;       #3
}

Inspect the complete CSS declaration and the list-style application together. section 4.2.4

How Tiny CSS Projects covers it

How deep it goes
Defines the at-rule, explains built-in list counting, and applies symbols, system, and suffix without broader counter mechanics.
Examples
Demonstrates a newspaper article's unordered list using a repeating hot-beverage emoji marker.
What it assumes
Builds on basic CSS and familiarizes readers with at-rules through comparison with keyframes.
What you can do after
Apply it via CSS to replace default list bullets with a named custom counter style.
How it connects
Connects CSS counters, list-style, at-rules, and the CSS Lists and Counters Module.

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.