Hi guys, I’ve been following some CSS lessons and I’ve seen people using:
.class > element {}.
for exemple
.wrapper > div {}
The purpose was to point to all the divs within the class .wrapper.
My question is the following; until now, To do the same, I’ve been using just:
.wrapper divs {}
without the ‘>’
Are those do the same? If not what’d be the difference?
Sorry to open a new Topic for just such silly question, but I couldn’t find a proper answer anywhere.
The > says that the next element has to be a direct child. So in a more complex HTML structure, it will be applied only to elements that are direct descendants.
While not writing > will affect all elements within, no matter how deep they are.
The symbol > when used will affect only the div that are directly in the class that means if a div in the class has another div in it, the div in it will not be affected only div that are directly inside the div
"< Div class= “wrapper” >
Level 1 div < Div>
Level 2 div < Div> < /Div>
… < / Div>
< /Div>"
If you use “>” Level 1 div would be affected and Level 2div won’t
If you use " space between them " Level 1 div would be affected also Level 2 div And all other div