Using the :only-of-type selector
Description
The :only-of-type selector matches elements that are the only child of their type defined by their parent.
Example
The following code uses the :only-of-type Selector.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:only-of-type {<!--from w w w . jav a 2 s. c o 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>