I have W3 selector reference open most of the time but I can’t seem to figure this out.
Below I have some CSS I want to tidy up. What is the correct selector for:
- Selecting everything inside a specific div, in this case .container2.
- Selecting say an img element only within a specific div? I can only seem to see selectors for children that comes after a generic element i.e div > img or div img.
I just seem to have loads of classes/ids and it all feels very messy and I’m creating a new CSS{} for each little change.
.container2, #blue, #yellow,
#pink, #image1, #image2,
#image3, span {
background-color: #A9DFBF;
}
//HTML//
<div class="container2">
<div id="image1">
<img id="yellow" src="https://i.ibb.co/VtsdZHt/yellowmac.png" height="80" alt="yellow macaron"><span class="text">Macarons have more in common with pasta than you thought..</span>
</div>
<div id="image2">
<img id="blue" src="https://i.ibb.co/S3sRwqT/bluemac.png" height="80" alt="blue macaron"> <span class="text"> It is the most popular sweet sold in France.</span>
</div>
<div id="image3">
<img id="pink" src="https://i.ibb.co/gMn6yqG/pinkmac.png" height="80" alt="pink macaron"> <span class="text">In North America, the coconut macaroon is the best known variety.</span></div>
</div>
Cheers!