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 elements that are
focusable due to contenteditable."> |
| 11 <style> |
| 12 /* Suppress things that cannot be reproduced in the reference file */ |
| 13 :focus { |
| 14 outline: none; |
| 15 |
| 16 /* Make the caret invisible |
| 17 since it matches the color of the text, which is transparent, |
| 18 while keeping the text readable thanks to its shadow. |
| 19 Not using the caret-color property as it is too new to be relied on. */ |
| 20 color: transparent; text-shadow: black 0px 0px 0px; |
| 21 } |
| 22 |
| 23 /* Use blue to indicate that the user needs to pay attention. |
| 24 This element needs to be focused for the test to make sense. */ |
| 25 #focusme:not(:focus) { |
| 26 border: solid 15px blue; |
| 27 } |
| 28 |
| 29 :focus { |
| 30 border: solid 5px red; |
| 31 } |
| 32 div:focus-within, #focusme:focus-within { |
| 33 border: solid 5px green; |
| 34 } |
| 35 </style> |
| 36 <p>Test passes if, when the element below is focused, |
| 37 it is surrounded by a thick green border. |
| 38 There must be no red or blue once it is focused.</p> |
| 39 <div> |
| 40 <div> |
| 41 <div id="focusme" class="reftest-wait" onfocus="this.classList.toggle('refte
st-wait');" contentEditable="true">Focus this element</div> |
| 42 </div> |
| 43 </div> |
| 44 <script> |
| 45 /* This script is an optional convenience, |
| 46 simply removing the need to manually focus the element. |
| 47 The test is valid even if the script is not run. */ |
| 48 var editor = document.getElementById('focusme'); |
| 49 editor.focus(); |
| 50 </script> |
| 51 </html> |
OLD | NEW |