Targeting a div inside a div

Example code:
https://jsfiddle.net/5x60gu95/

I want to target both divs (1 and 2), but they dont have any class or id. Halp pls

Why not give them a class or id then?

CSS descendent selectors will work here:

div div {
    background-color: tomato;
    display: block;
    width: 100px;
    height: 100px;
}

also as a note, if you only want to target one, you can use nth-of-type or nth-child

1 Like

Hey Elian,

Are you trying to target those divs with CSS or with JavaScript?

Sorry for the late answer i’ve already fix it but nth-of-type could have been another solution, thank you.