element-replacement-dynamic.html (783B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>The content CSS attribute can replace an element's contents dynamically</title> 4 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" /> 5 <link rel="match" href="element-replacement-ref.html" /> 6 <link rel="help" href="https://drafts.csswg.org/css-content-3/#content-property" /> 7 <meta name="assert" content"This test checks that the CSS content propertly can replace a normal element's contents when changed dynamically" /> 8 9 <style> 10 #target { 11 content: none; 12 } 13 #target.replaced { 14 content: url('resources/rect.svg'); 15 } 16 </style> 17 18 <div id="target">This text should not be visible</div> 19 20 <script> 21 const target = document.getElementById("target"); 22 getComputedStyle(target).width; 23 target.className = "replaced"; 24 </script>