focus-pseudo-class-002

:focus pseudo-class - adjacent sibling selector

WeasyPrint

This browser

Flags
interact
Assertion
An HTML 4 text input control must be focused in order to enter text into it. The :focus pseudo-class applies to a text input control while it has the focus (accepts keyboard events or other forms of text input).

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3 
 4  <head>
 5 
 6   <title>CSS Test: :focus pseudo-class - adjacent sibling selector</title>
 7 
 8   <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
 9   <link rel="help" href="http://www.w3.org/TR/html4/interact/forms.html#h-17.11">
10   <link rel="help" href="http://www.w3.org/TR/CSS21/selector.html#dynamic-pseudo-classes">
11   <link rel="help" href="http://www.w3.org/TR/CSS21/selector.html#adjacent-selectors">
12   <meta name="flags" content="interact">
13   <meta name="assert" content="An HTML 4 text input control must be focused in order to enter text into it. The :focus pseudo-class applies to a text input control while it has the focus (accepts keyboard events or other forms of text input).">
14 
15   <style type="text/css">
16   span
17   {
18   color: white;
19   }
20 
21   input:focus + span
22   {
23   color: green;
24   }
25   </style>
26 
27  </head>
28 
29  <body>
30 
31   <p>Enter in the text field below with the pointing device or with the keyboard (with the tab key or with the "T" accesskey) and then enter some text into it. A message in green should then have appeared on its right-hand side indicating that such text field has received focus. In order to pass this test, the tester should not have to move the pointing device outside the text field.</p>
32 
33   <div>
34    <input type="text" accesskey="T" tabindex="1"> <span>Focus received by text field</span>
35   </div>
36 
37  </body>
38 </html>