Does spacing matter when using CSS combinators?

Does one need to add space when trying to be specific with targeting a CSS selector? For example, when targeting a class that is a child of an HTML elements, should there be a space between the parent element and the child class that is being targeted, as in this exercise here

It appears that when I add space, I see the effect but when I don’t, I don’t see the effect.

Do mean like this?

<div class="parent">
  <p class="child">
    A very long important paragraph about important stuff.
  </p>
</div>
div .child { //spacing in selector
  color: red;
} 

VERSUS:

div.child {  //no spacing in selector
  color: red;
}

If so than yes the spacing matters.

Without the space div.child the code is checking for <div> elements that have a class of child.

Whereas div .child is checking for elements that are children of a <div> and have a class of child.

3 Likes

Awesome! :smile: That was what I meant and thanks for the clarification.

1 Like