prefix

The prefix descriptor of the @counter-style rule specifies content that will be prepended to the marker representation. If not specified, the default value will be "" (an empty string).

Syntax

/* <symbol> values */
prefix: "»";
prefix: "Page ";
prefix: url(bullet.png);

Values

<symbol>

Specifies a <symbol> that is prepended to the marker representation. It may be a <string>, <image>, or <custom-ident>.

Formal definition

Related at-rule@counter-style
Initial value"" (the empty string)
Computed valueas specified

Formal syntax

prefix = 
<symbol>

<symbol> =
<string> |
<image> |
<custom-ident>

<image> =
<url> |
<gradient>

<url> =
url( <string> <url-modifier>* ) |
src( <string> <url-modifier>* )

Examples

Adding a prefix to a counter

HTML

<ul class="index">
  <li>The Boy Who Lived</li>
  <li>The Vanishing Glass</li>
  <li>The Letters from No One</li>
  <li>The Keeper of the Keys</li>
  <li>Diagon Alley</li>
</ul>

CSS

@counter-style chapters {
  system: numeric;
  symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
  prefix: "Chapter ";
}

.index {
  list-style: chapters;
  padding-left: 15ch;
}

Result

Specifications

Specification
CSS Counter Styles Level 3
# counter-style-prefix

Browser compatibility

BCD tables only load in the browser

See also