counter-slot-order.html (1040B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS counter order and scope with Shadow DOM and SLOT</title> 5 <link rel="author" title="Martin Robinson" href="mailto:mrobinson@igalia.com"> 6 <link rel="help" href="https://www.w3.org/TR/css-lists-3/#inheriting-counters"> 7 <link rel="match" href="counter-slot-order-ref.html"> 8 <style> 9 .counted { 10 counter-increment: section; 11 } 12 13 .counted::before { 14 content: "C=" counter(section) " "; 15 } 16 </style> 17 </head> 18 19 <body> 20 <div id="host"> 21 <div class="counted" slot="content3">Three</div> 22 <div class="counted" slot="content2">Two</div> 23 <div class="counted" slot="content1">One</div> 24 </div> 25 26 <script> 27 const shadowRoot = document 28 .getElementById('host') 29 .attachShadow({mode: 'open'}); 30 shadowRoot.innerHTML = ` 31 <div> 32 <slot name="content1"></slot> 33 <slot name="content2"></slot> 34 <slot name="content3"></slot> 35 </div> 36 `; 37 </script> 38 39 </body> 40 </html>