counters-scope-004.html (1080B)
1 <!doctype html> 2 <title>CSS Lists and Counters: counters scope</title> 3 <link rel="help" href="https://drafts.csswg.org/css-lists/#inheriting-counters"> 4 <link rel="match" href="counters-scope-004-ref.html"> 5 <meta name="assert" content="counters are not inherited from the previous sibling, when can be inherited from the ancestor"> 6 <style type="text/css"> 7 .reset { counter-reset: c; } 8 .rb::before { counter-reset: c; content: "R"; } 9 .use { counter-increment: c; } 10 .use::before { content: counters(c, ".") " "; } 11 </style> 12 <p>The following two lines should be the same:</p> 13 <!-- As rb creates counter only on ::before, the first span with class "use" --> 14 <!-- inside the "rb" will inherit its counter from second "reset" as span "rb" --> 15 <!-- will inherit it from previous sibling which is second "reset" --> 16 <div> 17 <span class="reset"></span> 18 <span class="use"></span> 19 <span class="reset"></span> 20 <span class="use"></span> 21 <span class="rb"> 22 <span class="use"></span> 23 <span class="reset"></span> 24 <span class="use"></span> 25 </span> 26 </div> 27 <div>1 1 R 2 3</div>