enter code here
<div class="test">
<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 the test class
But I don't know how to do that without having an tr or td here
enter code here
<div class="test">
<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 the test class
But I don't know how to do that without having an tr or td here
You can use the nth-child()
selector to achieve this:
Some more answers here if you want to understand it further nth child selector`
.test p:nth-child(2) {
color: red;
}
<div class="test">
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
div.test p:nth-child(2) {
background-color: red;
}
<div class="test">
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>