What is the primary purpose of CSS counters?
A
To count elements automatically
B
To style elements based on position
C
To create numbered lists or custom counters
D
To count the number of clicks
Analysis & Theory
CSS counters are used to create automatic numbering for elements like lists or headings.
Which CSS property is used to initialize a counter?
Analysis & Theory
`counter-reset` initializes or resets the value of a counter.
Which property increments a CSS counter by a specified value?
Analysis & Theory
`counter-increment` increases the value of a counter.
How do you display the current value of a counter in CSS?
A
Using `content: counter(name);`
B
Using `content: attr(name);`
C
Using `content: value(name);`
D
Using `content: current(name);`
Analysis & Theory
The `content` property with `counter(name)` inserts the current counter value.
What is the default starting value of a CSS counter when reset?
Analysis & Theory
By default, counters start at 0 unless specified otherwise in `counter-reset`.
How can you specify the starting value of a CSS counter to 5?
A
counter-reset: myCounter;
B
counter-reset: myCounter 5;
C
counter-increment: myCounter 5;
D
counter-set: myCounter 5;
Analysis & Theory
`counter-reset: myCounter 5;` sets the initial value of the counter to 5.
Which CSS pseudo-element is commonly used to insert counter values before elements?
Analysis & Theory
`::before` inserts generated content before an element, often used with counters.
How do you increment a counter by 2 instead of 1?
A
counter-increment: myCounter 2;
B
counter-reset: myCounter 2;
C
counter-increment: myCounter;
D
counter-set: myCounter 2;
Analysis & Theory
`counter-increment: myCounter 2;` increases the counter by 2 each time.
Which function allows combining multiple counters with a separator?
Analysis & Theory
`counters(name, string)` concatenates multiple counters separated by the specified string.
CSS counters can be used to number which types of elements?
Analysis & Theory
CSS counters can number any element as long as you apply the counter properties correctly.