Is it possible to use parent child:nth-child()
and only apply to child's?
The html is the following:
<body>
<div>div 1</div>
<div>
div 2
<div>div 2.1</div>
<div>div 2.2</div>
</div>
</body>
And I wanted to select with CSS: div 1 & div 2
, I used:
body div:nth-of-type(1) {
background: red;
color: white;
}
body div:nth-child(2) {
background: blue;
}
But div 2.1 & 2.21
got selected too. JSFiddle
Is it possible to do a non recursive selection? If not I guess the only solution are clases or id's..