To have a "<" or not in an HTML element?

let’s say I am targeting all images within <div class="gallery>

in the CSS it doesn’t make a difference if I use .gallery img { } or .gallery > img { }

it doesn’t make a difference? Just two different ways to call that class?

I tried it out on my laptop and I don’t see any difference.

not for any specific project, and also no particular problem at the moment. I am just confirming and observation I made… To be exact, I am working on my product landing page project at that moment and it will include a flexbox gallery.

This second example makes use of the child combinator which target the direct child of the parent element.

Here is a basic example

This code here

.container > p {
  color: red;
}

will only style paragraph elements that are direct children of the container class.

But this code here

.container  p {
  color: red;
}

will style all paragraph elements inside the container class

You can try it out yourself and you will see the style changes.

You can see more example on the child combinator here in the docs

thanks a lot. I got it :grin:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.