display-contents-dynamic-before-after-first-letter-001.html (788B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Display: Dynamic changes to ::before and ::after on display:contents when ::first-letter is in effect</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:ecobos@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/css-display-3/#valdef-display-contents"> 6 <link rel="match" href="display-contents-pass-green-no-red-ref.html"> 7 <style> 8 div { color: blue; } 9 div::first-letter { color: red; } 10 div::before { display: contents; content: "PASS"; border: 1px solid red; } 11 .active div::before, 12 .active div::first-letter { color: green; } 13 </style> 14 <p>You should see the word PASS in green and no red below.</p> 15 <div></div> 16 <script> 17 document.body.offsetTop; 18 document.body.className = "active"; 19 </script>