Issue
I have a quiz to change styling for two (p) inside (div) elements but the first one the border color is #ff5622
, and the second has a different color like this image How to do that
<div>
<p>This Is Paragraph</p>
</div>
Solution
You can take a look at the nth-child selector.
The :nth-child(n) selector matches every element that is the nth child, regardless of type, of its parent.
n can be a number, a keyword, or a formula.
Tip: Look at the :nth-of-type() selector to select the element that is the nth child, of a particular type, of its parent.
Or the nth-of-type property.
If your HTML is :
div:nth-of-type(1) > p {
color: red;
}
div:nth-of-type(2) > p {
color: blue;
}
<div>
<p>First paragraph</p>
</div>
<div>
<p>Second paragraph</p>
</div>
Answered By - Théo Benoit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.