css 3

Icon

A comprehensive CSS 3 reference guide, tutorial, and blog
Are you a CSS expert? Want to contribute? Contact us

CSS COUNTER-INCREMENT

The ‘counter-increment’ property acts like an incremented variable in a programming language – it specifies the amount to increment the specified counter by when the current CSS selector is encountered. The property lists one or more counter labels, each followed by an optional increment integer value (default increment is 1.) Negative integers and zero are also valid.

If a counter is incremented AND rendered using a single CSS selector (with the ‘content’ property and ‘before:’/'after:’ pseudo-elements), it should be incremented first, then rendered. If a single CSS selector both increments and resets a counter, it is reset, then incremented.

 

Example

h1:before {counter-increment: main-heading; counter-reset: sub-heading; content: “Section ” counter(main-heading) “:” }

 

Possible Values

Value Description
inherit Explicitly sets the value of this property to that of the parent.
none Suppresses incrementing counters for the current selector.
[identifier integer] Specifies one or more counters and the amount to increment the counter by.

 

One Response

  1. Meettya says:

    Is it in example mean :

    h1:before {counter-increment: main-heading; counter-reset: sub-heading; content: “Section ” counter(main-heading) “:” counter(sub-heading)}

    ?

    I should think so!

Leave a Reply

Pages

Sponsors


CSS3.com



Please help CSS3.com stay alive and running

Bad Behavior has blocked 2189 access attempts in the last 7 days.