focus-within-007.html (1231B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <meta charset="utf-8"> 4 <title>Selectors Level 4: focus-within</title> 5 <link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> 6 <link rel="help" href="https://drafts.csswg.org/selectors-4/#focus-within-pseudo"> 7 <link rel="match" href="focus-within-007-ref.html"> 8 <meta name="assert" content="Checks that ':focus-within' can be used as universal selector."> 9 <style> 10 /* Suppress things that cannot be reproduced in the reference file */ 11 :focus { 12 outline: none; 13 } 14 html, body, div { 15 border: solid 5px red; 16 } 17 /* Use blue to indicate that the user needs to pay attention. 18 This element needs to be focused for the test to make sense. */ 19 div { 20 border-color: blue; 21 } 22 :focus-within { 23 border-color: green; 24 } 25 </style> 26 <p>Test passes if, when the element below is focused, it is surrounded by a green border, and HTML and BODY elements also have a green border. There must be no red or blue once it is focused.</p> 27 <div id="focusme" tabindex="1">Focus this element</div> 28 <script> 29 var focusme = document.getElementById('focusme'); 30 focusme.focus(); 31 document.documentElement.classList.remove('reftest-wait'); 32 </script> 33 </html>