contain-style-dynamic-002-ref.html (489B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <style> 4 ol { 5 list-style: inside decimal; 6 padding-inline-start: 1em; 7 counter-reset: c 0; 8 } 9 li { 10 counter-increment: c 1; 11 } 12 div { 13 contain: style; 14 } 15 :is(ol, li, div) { 16 padding-left: 1em; 17 } 18 :is(ol, li, div)::before { 19 content: "[::before=" counters(c, ".") "]"; 20 } 21 :is(ol, li, div)::after { 22 content: "[::after=" counters(c, ".") "]"; 23 } 24 div::before { 25 color: red; 26 } 27 </style> 28 <ol> 29 <li></li> 30 <div> 31 <li></li> 32 </div> 33 <li></li> 34 </ol>