Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1132203 of counter-increment

  • Revision slug: Web/CSS/counter-increment
  • Revision title: counter-increment
  • Revision id: 1132203
  • Created:
  • Creator: Sebastianz
  • Is current revision? Yes
  • Comment Fixed spec. anchor

Revision Content

{{CSSRef}}

Summary

The counter-increment CSS property is used to increase the value of CSS Counters by a given value. The counter's value can be reset using the {{cssxref("counter-reset")}} CSS property.

{{cssinfo}}

Syntax

/* Increment 'counter-name' by 1 */
counter-increment: counter-name;

/* Decrement 'counter-name' by 1 */
counter-increment: counter-name -1;

/* Increment 'counter1' by 1, and decrement 'counter2' by 4 */
counter-increment: counter1 counter2 -4;

/* Do not increment/decrement anything: used to hide less specific values */
counter-increment: none;

/* Global values */
counter-increment: inherit;
counter-increment: initial;
counter-increment: unset;

Values

{{cssxref("<custom-ident>")}}
The name of the counter to increment. This identifier is composed by a combination of case-insensitive letters a to z, numbers 0 to 9, underscores (_), and/or dashes (-). The first non-dash character must be a letter (that is, no number at the beginning of it, even if preceded by a dash.) Also, two dashes are forbidden at the beginning of the identifier. It can't be none, unset, initial, or inherit in any combination of cases.
{{cssxref("<integer>")}}
The value to add to the counter. Defaults to 1 if not given.
none
No counter must be incremented. This is used as the default value, or to cancel an increment in more specific rules.

You may specify as many counters to increment as you want, each separated by a space.

Formal syntax

{{csssyntax}}

Examples

h1 {
  counter-increment: chapter section 2 page;
  /* Increases the value of the chapter and page counters by 1
     and the section counter by 2. */
}

Specifications

Specification Status Comment
{{SpecName("CSS3 Lists", "#propdef-counter-increment", "counter-increment")}} {{Spec2("CSS3 Lists")}} No change
{{SpecName("CSS2.1", "generate.html#propdef-counter-increment", "counter-increment")}} {{Spec2("CSS2.1")}} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 2.0 1.0 8.0 9.2 {{CompatVersionUnknown}}[1]
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] This feature is probably implemented since Safari 3.0.

See also

Revision Source

<div>{{CSSRef}}</div>

<h2 id="Summary">Summary</h2>

<p>The <strong><code>counter-increment</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> property is used to increase the value of <a href="/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters">CSS Counters</a> by a given value. The counter's value can be reset using the {{cssxref("counter-reset")}} CSS property.</p>

<p>{{cssinfo}}</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush:css">
/* Increment 'counter-name' by 1 */
counter-increment: counter-name;

/* Decrement 'counter-name' by 1 */
counter-increment: counter-name -1;

/* Increment 'counter1' by 1, and decrement 'counter2' by 4 */
counter-increment: counter1 counter2 -4;

/* Do not increment/decrement anything: used to hide less specific values */
counter-increment: none;

/* Global values */
counter-increment: inherit;
counter-increment: initial;
counter-increment: unset;
</pre>

<h3 id="Values">Values</h3>

<dl>
 <dt>{{cssxref("&lt;custom-ident&gt;")}}</dt>
 <dd>The name of the counter to increment. This identifier is composed by a combination of case-insensitive letters <code>a</code>&nbsp;to&nbsp;<code>z</code>, numbers <code>0</code>&nbsp;to&nbsp;<code>9</code>, underscores (<code>_</code>), and/or dashes (<code>-</code>). The first non-dash character must be a letter (that is, no number at the beginning of it, even if preceded by a dash.) Also, two dashes are forbidden at the beginning of the identifier. It can't be <code>none</code>, <code>unset</code>, <code>initial</code>, or <code>inherit</code> in any combination of cases.</dd>
 <dt>{{cssxref("&lt;integer&gt;")}}</dt>
 <dd>The value to add to the counter. Defaults to 1 if not given.</dd>
 <dt><code>none</code></dt>
 <dd>No counter must be incremented. This is used as the default value, or to cancel an increment in more specific rules.</dd>
</dl>

<p>You may specify as many counters to increment as you want, each separated by a space.</p>

<h3 id="Formal_syntax">Formal syntax</h3>

<pre class="syntaxbox">
{{csssyntax}}</pre>

<h2 id="Examples">Examples</h2>

<pre class="brush: css">
h1 {
  counter-increment: chapter section 2 page;
  /* Increases the value of the chapter and page counters by 1
     and the section counter by 2. */
}
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("CSS3 Lists", "#propdef-counter-increment", "counter-increment")}}</td>
   <td>{{Spec2("CSS3 Lists")}}</td>
   <td>No change</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS2.1", "generate.html#propdef-counter-increment", "counter-increment")}}</td>
   <td>{{Spec2("CSS2.1")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>2.0</td>
   <td>1.0</td>
   <td>8.0</td>
   <td>9.2</td>
   <td>{{CompatVersionUnknown}}<sup>[1]</sup></td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE&nbsp;Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] This feature is probably implemented since Safari 3.0.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters">Using CSS Counters</a></li>
 <li>{{cssxref("counter-reset")}}</li>
</ul>
Revert to this revision