cascade-highlight-005.html (2270B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Pseudo-Elements Test: inheritance of selection highlight background color from its parent element</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-005-ref.html"> 10 11 <meta name="assert" content="In this test, 'background-color' has not been specified a value for the highlight pseudo-element of the span element. Since the span's parent element has an highlight pseudo-element also, then the span's background color for its highlight pseudo-element should be inherited from its parent highlight pseudo-element. Therefore the span element should have a green background color."> 12 13 <!-- 14 15 This is a modified version of Example 11 16 https://www.w3.org/TR/css-pseudo-4/#example-c35bf49a 17 found in § 3.5 Cascading and Per-Element Highlight Styles 18 https://www.w3.org/TR/css-pseudo-4/#highlight-cascade 19 20 --> 21 22 <!-- 23 When any supported property is not given a value by the 24 cascade, its value is determined by inheritance from the 25 corresponding highlight pseudo-element of its originating 26 element's parent element (regardless of whether that property 27 is an inherited property). 28 https://www.w3.org/TR/css-pseudo-4/#highlight-cascade 29 --> 30 31 <link rel="stylesheet" href="../support/highlights.css"> 32 33 <style> 34 div 35 { 36 font-size: 300%; 37 } 38 39 div::selection 40 { 41 background-color: green; 42 color: yellow; 43 } 44 45 span::selection 46 { 47 color: orange; 48 } 49 </style> 50 51 <script> 52 function startTest() 53 { 54 var targetRange = document.createRange(); 55 /* We first create an empty range */ 56 targetRange.selectNodeContents(document.getElementById("test")); 57 /* Then we set the range boundaries to the children of div#test */ 58 window.getSelection().addRange(targetRange); 59 /* Finally, we now select such range of content */ 60 } 61 </script> 62 63 <body onload="startTest();"> 64 65 <p>Test passes if "Text selected" has a green background throughout, if "Tex" and "cted" are yellow and if "t sele" are orange. 66 67 <div id="test" class="highlight_reftest">Tex<span>t sele</span>cted</div>