I have a div class called index and inside that, I have two more div without class or id name and two <p> tags. I want to apply the style for these two <p> tags.
<div class="doubt">
<div>
<p>Hello world</p>
<div>
<p>Hello</p>
</div>
</div>
</div>
How to apply different style for two p tags?
Please help me out from this, Thanks in Advance!
Simple Just use this css
Let me know any further clearification.
.doubt > div > div > p {
color: green;
}
.doubt > div > p {
color: red;
}
<div class="doubt">
<div>
<p>Hello world</p>
<div>
<p>Hello</p>
</div>
</div>
</div>
You can use inline styling.
<div class="doubt">
<div>
<p style="color: yellow">Hello world</p>
<div>
<p style="color: red">Hello</p>
</div>
</div>
</div>
as well you you can use hierarchical structure in style to apply styling on these paragraphs.
<head>
<style>
.doubt div p{
color: red;
}
.doubt div div p{
color: green;
}
</style>
</head>
<body>
<div class="doubt">
<div>
<p>Hello world</p>
<div>
<p>Hello</p>
</div>
</div>
</div>
</body>
hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With