cascade-highlight-002.html (1632B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Pseudo-Elements Test: tag selector missing (Example 12)</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-cascade"> 9 <link rel="match" href="cascade-highlight-001-ref.html"> 10 11 <!-- 12 Example 12 is 13 https://www.w3.org/TR/css-pseudo-4/#example-97480f68 14 --> 15 16 <meta name="assert" content="This test is an adaptation (or modified version) of Example 12 (#example-97480f68). In this test, <span> element's ::selection matches the ::selection { background-color: green; } rule and not the div#test::selection rule because '*' is implied when a tag selector is missing."> 17 18 <link rel="stylesheet" href="../support/highlights.css"> 19 <style> 20 div 21 { 22 font-size: 300%; 23 } 24 25 ::selection 26 { 27 background-color: green; 28 color: yellow; 29 } 30 31 div#test::selection 32 { 33 background-color: red; 34 color: black; 35 } 36 </style> 37 38 <script> 39 function startTest() 40 { 41 var targetRange = document.createRange(); 42 /* We first create an empty range */ 43 targetRange.selectNodeContents(document.getElementById("test")); 44 /* Then we set the range boundaries to the children of div#test */ 45 window.getSelection().addRange(targetRange); 46 /* Finally, we now select such range of content */ 47 } 48 </script> 49 50 <body onload="startTest();"> 51 52 <p>Test passes if background color of "Text sample" is green and <strong>not red</strong>. 53 54 <div id="test" class="highlight_reftest"><span>Text sample</span></div>