OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html lang=en> |
| 3 <meta charset="utf-8"> |
| 4 <title>Selectors Level 4: focus-within</title> |
| 5 <link rel="author" title="Keyong Li" href="mailto:kli79@bloomberg.net"> |
| 6 <link rel="author" title="Florian Rivoal" href="mailto:florian@rivoal.net"> |
| 7 <link rel="help" href="https://drafts.csswg.org/selectors-4/#focus-within-pseudo
"> |
| 8 <link rel="match" href="focus-within-001-ref.html"> |
| 9 <meta name="flags" content="interact"> |
| 10 <meta name="assert" content="Test that :focus-within works on links."> |
| 11 <style> |
| 12 /* Suppress things that cannot be reproduced in the reference file */ |
| 13 :focus { |
| 14 outline: none; |
| 15 } |
| 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 #focusme:not(:focus) { |
| 20 border: solid 15px blue; |
| 21 } |
| 22 |
| 23 /* Make the link look like the div in the reference file */ |
| 24 #focusme { |
| 25 display: block; |
| 26 text-decoration: none; |
| 27 color: currentColor; |
| 28 } |
| 29 |
| 30 :focus { |
| 31 border: solid 5px red; |
| 32 } |
| 33 div:focus-within, #focusme:focus-within { |
| 34 border: solid 5px green; |
| 35 } |
| 36 </style> |
| 37 <p>Test passes if, when the element below is focused, |
| 38 it is surrounded by a thick green border. |
| 39 There must be no red or blue once it is focused.</p> |
| 40 <div> |
| 41 <div> |
| 42 <a id="focusme" class="reftest-wait" onfocus="this.classList.toggle('reftest
-wait');" href="">Focus this element</a> |
| 43 </div> |
| 44 </div> |
| 45 <script> |
| 46 /* This script is an optional convenience, |
| 47 simply removing the need to manually focus the element. |
| 48 The test is valid even if the script is not run. */ |
| 49 var editor = document.getElementById('focusme'); |
| 50 editor.focus(); |
| 51 </script> |
| 52 </html> |
OLD | NEW |