hello friends how can I target p inside multiple sepecific elements ??

for example paragraph inside many sections elements they have different ids they are all withing article element??
2 Replies
Tok124 (CSS Nerd)
You could apply a class to each section. You should not target ids in your css anyway. But using id in your html can be useful since you can link to an id and it will scroll down to that section. So you can do
<section class="section" id="section1">
<p>some text</p>
</section>
<section class="section" id="section2">
<p>some text</p>
</section>
<section class="section" id="section3">
<p>some text</p>
</section>
<section class="section" id="section4">
<p>some text</p>
</section>
<section class="section" id="section5">
<p>some text</p>
</section>
<section class="section" id="section1">
<p>some text</p>
</section>
<section class="section" id="section2">
<p>some text</p>
</section>
<section class="section" id="section3">
<p>some text</p>
</section>
<section class="section" id="section4">
<p>some text</p>
</section>
<section class="section" id="section5">
<p>some text</p>
</section>
.section p {
color:red;
}
.section p {
color:red;
}
Or you could remove the id and do
<section class="section section1">
<p>some text</p>
</section>
<section class="section section2">
<p>some text</p>
</section>
<section class="section section3">
<p>some text</p>
</section>
<section class="section section4">
<p>some text</p>
</section>
<section class="section section5">
<p>some text</p>
</section>
<section class="section section1">
<p>some text</p>
</section>
<section class="section section2">
<p>some text</p>
</section>
<section class="section section3">
<p>some text</p>
</section>
<section class="section section4">
<p>some text</p>
</section>
<section class="section section5">
<p>some text</p>
</section>
So now youc an target all sections with .section or you can target one of them with .section3 for example
AnasYasien
AnasYasienOP2y ago
thank you so much
Want results from more Discord servers?
Add your server