Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>CSS Test: :focus pseudo-class - adjacent sibling selector</title>
<link rel="author" title="GĂ©rard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<meta name="flags" content="interact" />
<meta name="assert" content="An HTML 4 radio button must receive focus state when clicking on it or when selecting it with the keyboard. The :focus pseudo-class applies to a radio button while it has the focus (accepts keyboard events or other forms of input)." />
<style type="text/css"><![CDATA[
input[type="radio"]
{
height: 20px;
width: 60px;
}
input[type="radio"]:focus + label
{
background-color: yellow;
color: black;
}
]]></style>
</head>
<body>
<p>With the pointing device (like a mouse left-button click) or with the keyboard (with the tab key or with the "T" accesskey), activate the radio button below. The words "Text sample" on its right-hand side should then have become highlighted in yellow. In order to pass this test, the tester should not have to move the pointing device out of the radio button in order to see the yellow highlighting.</p>
<div>
<input type="radio" id="test" accesskey="T" /> <label for="test">Text sample</label>
</div>
</body>
</html>