Using the :only-child Selector
Description
The :only-child selector matches elements that are the only elements contained by their parent.
Example
The following code uses the :only-child Selector.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:only-child {<!-- w ww.j a v a 2 s . co m-->
border: thin black solid;
padding: 4px;
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the website</a>
<p>
I like <span>HTML</span>.
</p>
<a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>