<div class="first tempbg">
First div Text
<section id="sec1" class="">
Section 1 Text
<div class="insidefirst tempbg">
Div 1 Text
<p class="">Paragraph 1</p>
</div>
</section>
<article id="art1" class="">
Article 1 Text
<div class="insidefirst tempbg">
Div 2 Text
<p class="">Paragraph 2</p>
</div>
</article>
</div>
Asked
Active
Viewed 23 times
0

Hitesh B.K
- 1
- 1
-
Use `id` for that `div` – najmieh sadat safarabadi Jan 12 '22 at 18:09
-
Its not working iJust want ot select this from the code First div Text – Hitesh B.K Jan 12 '22 at 18:12
-
Do you mean this `` one?– najmieh sadat safarabadi Jan 12 '22 at 18:13
-
Yeah the text betweenand– Hitesh B.K Jan 12 '22 at 18:14
If u can send the selector it would be a great help -
Use `` tag for the text. Follow this `First div Text` you can use class attribute for this as well. – najmieh sadat safarabadi Jan 12 '22 at 18:16
-
i cant change the code this is from a site i cant change anything i have to select from this only – Hitesh B.K Jan 12 '22 at 18:18
1 Answers
0
first way :
First div Text Section 1 Text Div 1 Text Paragraph 1 Article 1 Text Div 2 Text Paragraph 2div.section.insidefirst { #your css background-color:red }
second way: div.section:first-child { background-color:red }
The ":first-child" selector allows you to target the first element immediately inside another element. It is defined in the CSS Selectors Level 3 spec as a “structural pseudo-class”, meaning it is used to style content based on its relationship with parent and sibling content.

Assassin dev
- 36
- 4