Export (0) Print
Expand All
top
Expand Minimize

counter-increment

Expression Studio 4.0
important noteImportant

This documentation is preliminary and is subject to change.

Sets a list of counters to increment.

Syntax

{ counter-increment: sCounter }

Possible values

sCounter

String that specifies a space-delimited list of counters, including one or both of the following values.

identifier

The name of the counter, optionally followed by an increment.

increment

An integer that indicates by how much the counter is incremented for every occurrence of the element. Zero and negative integers are allowed.

This property has no default value. It is not inherited.

Remarks

The counter-increment attribute can contain a list of one or more counters, each one optionally followed by an integer. The integer represents the amount that the counter is incremented after each occurrence of an element.

This property is used to generate numbered content for each occurrence of an element. The counter need not be defined before it is incremented. To reset a counter value, use the counter-reset attribute.

The counter-increment and counter-reset attributes follow the rules of the CSS cascade. Given two style declarations with the same specificity, only the last one encountered will be processed.

An element that is not displayed (display attribute set to none) and pseudo-elements that do not generate content (content attribute set to normal) cannot increment or reset a counter.

Example

The following example demonstrates automatic chapter and section numbering using counter-reset, counter-increment, and content. The chapter counter is set to zero for the body element, and then incremented for each h1 element encountered. The section counter is reset for each h1 element and incremented for each h2 element. When the page is viewed, each h1 element is preceded by a chapter heading of the form "Chapter X. ", while each h2 element is preceded by a section number of the form "X.N ".

<meta http-equiv="X-UA-Compatible" content="IE=8" />
<style type="text/css">
body {
    counter-reset: chapter;      /* Create a chapter counter */
}
h1 {
    counter-increment: chapter;  /* Add 1 to chapter */
    counter-reset: section;      /* Set section to 0 */
}
h1:before {
    content: "Chapter " counter(chapter) ". ";
}
h2 {
    counter-increment: section;
}
h2:before {
    content: counter(chapter) "." counter(section) " ";
}
</style>

Because of a conflicting set of style rules, in the following example only the imagenum counter is reset. To reset both counters, put them together in the same rule.

h1 { counter-reset: section -1 }
h1 { counter-reset: imagenum 99 }

Standards information

Applies to

a, address, b, big, blockquote, body, button, caption, center, cite, code, col, colgroup, custom, dd, defaults, dfn, div, dl, dt, em, fieldset, form, hn, html, i, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, li, ol, p, s, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2015 Microsoft