0
<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>

1 Answers1

0

first way :

First div Text Section 1 Text Div 1 Text Paragraph 1 Article 1 Text Div 2 Text Paragraph 2

div.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.