enter code here
<div >
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
I tried to change the text color of second paragraph tag only to red using class test
but i dont know how to do that without having an tr or td here
CodePudding user response:
div.test p:nth-child(2) {
background-color: red;
}
<div >
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
CodePudding user response:
You can use the nth-child()
selector to achieve this:
.test p:nth-child(2) {
color: red;
}
<div >
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>