The :only-child
selector
matches the only child element.
:only-child { style properties }
:only-child |
Yes | 9.0 | Yes | Yes | Yes |
An example showing how to use :only-child CSS selector.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:only-child { <!--from w ww. ja v a2s .c o m-->
border: thin black solid;
padding: 4px;
}
</style>
</head>
<body>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
</body>
</html>