22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Value: [ ? ]+ | none | inherit<br />

Initial: none<br />

Applies to: all elements<br />

Inherited: no<br />

Percentages: N/A<br />

Media: all<br />

’counter-increment’<br />

Value: [ ? ]+ | none | inherit<br />

Initial: none<br />

Applies to: all elements<br />

Inherited: no<br />

Percentages: N/A<br />

Media: all<br />

The ’counter-increment’ property accepts one or more names of counters<br />

(identifiers), each one optionally followed by an integer. The integer indicates by<br />

how much the counter is incremented for every occurrence of the element. The<br />

default increment is 1. Zero and negative integers are allowed.<br />

The ’counter-reset’ property also contains a list of one or more names of counters,<br />

each one optionally followed by an integer. The integer gives the value that<br />

the counter is set to on each occurrence of the element. The default is 0.<br />

If ’counter-increment’ refers to a counter that is not in the scope (see below<br />

[p. 162] ) of any ’counter-reset’, the counter is assumed to have been reset to 0<br />

by the root element.<br />

Example(s):<br />

This example shows a way to number chapters and sections with "Chapter 1",<br />

"1.1", "1.2", etc.<br />

H1:before {<br />

content: "Chapter " counter(chapter) ". ";<br />

counter-increment: chapter; /* Add 1 to chapter */<br />

counter-reset: section; /* Set section to 0 */<br />

}<br />

H2:before {<br />

content: counter(chapter) "." counter(section) " ";<br />

counter-increment: section;<br />

}<br />

If an element increments/resets a counter and also uses it (in the ’content’<br />

property of its :before or :after pseudo-element), the counter is used after being<br />

incremented/reset.<br />

If an element both resets and increments a counter, the counter is reset first<br />

and then incremented.<br />

The ’counter-reset’ property follows the cascading rules. Thus, due to cascading,<br />

the following style sheet:<br />

H1 { counter-reset: section -1 }<br />

H1 { counter-reset: imagenum 99 }<br />

161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!