0

As you can see below only the last counter-increment will work. is this a bug or a feature ? is there any way to use multiple counter-increment other than using different selectors ?

input#p1:checked {
  counter-increment: --t1 5;
}
input#p2:checked {
  counter-increment: --t1 5;
  counter-increment: --t2 5; /* only the last one works */
}

input#p3:checked {
  counter-increment: --t1 5;
  counter-increment: --t2 5;
  counter-increment: --dummy 5; /* only the last one works */
}

#result::after {
  content: counter(--t1) '*' counter(--t2) ' points';
}
<input type="checkbox" id="p1">
<input type="checkbox" id="p2">
<input type="checkbox" id="p3">

<div id="result">result: </div>

2 Answers 2

1

counter-increment is a css property like many others. You can only set it ounce inside the element. Basically, the last value overwrites any previous values.

Sign up to request clarification or add additional context in comments.

Comments

0

after testing a bit more i found the answer myself. you can use as many counters as you want with counter-increment , also thanks to @Mauricio to remind me its a css property like many others.

input#p1:checked {
  counter-increment: --t1 5;
}
input#p2:checked {
  counter-increment: --t1 5 --t2 5;
}

input#p3:checked {
  counter-increment: --t1 5 --t2 5;
}

#result::after {
  content: counter(--t1) '*' counter(--t2) ' points';
}
<input type="checkbox" id="p1">
<input type="checkbox" id="p2">
<input type="checkbox" id="p3">

<div id="result">result: </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.