CSS Selector :nth-of-type(n)
Description
:nth-of-type(n)
selects elements that are the nth child of their type.
The argument is the index of the element.
The indexes start at 1.
Example
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
body > :nth-of-type(2) { <!--from w w w . ja v a 2s. c o m-->
border: thin black solid;
padding: 4px;
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
</body>
</html>
The code above generates the following result.