focus-within-010.html (1077B)
1 <!DOCTYPE html> 2 <html lang=en 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-shadow-001-ref.html"> 8 <meta name="assert" content="Checks that :focus-within is still applied when focus moves from an element to one of its descendants."> 9 <style> 10 /* Suppress things that cannot be reproduced in the reference file */ 11 :focus { 12 outline: none; 13 } 14 15 #target { 16 display: none; 17 } 18 19 #wrapper:focus-within > #target { 20 display: block; 21 } 22 23 #target:focus { 24 border: solid 15px green; 25 } 26 </style> 27 <p>Test passes if there is a green rectangle below.</p> 28 <div id="wrapper" tabindex="1"> 29 <div id="target" tabindex="2"></div> 30 </div> 31 <script> 32 var wrapper = document.getElementById('wrapper'); 33 wrapper.focus(); 34 var target = document.getElementById('target'); 35 target.focus(); 36 document.documentElement.classList.remove('reftest-wait'); 37 </script> 38 </html>