Can you have spaces in classes?

I’m studying the example given for the FCC Portfolio Project here:

https://codepen.io/El_Escandalo/pen/PoYXzQJ?editors=1100

User-Story 4 of that project requires the use of an element with the class “project-tile”.

In the example, the a elements contain classes of “project project-tile”.

My questions are:

  1. Can you have a space in a class? (the space between “project” and “project-tile”?)
  2. Do portions of a class also become classes? For example, if I have a class="a b-c", are both “a” and “b-c” classes then? Is “a b-c” also a 3rd class?
  3. Or is this some way of trying to indicate a parent-child relationship where it’s being signified that “project-tile” is a child of “project”?

I just never saw spaces in classes before. Thank you!

1 Like

1. Can you have a space in a class? (the space between “project” and “project-tile”?)

If you put a space in a class, that actually means you are giving it a different class.
So “project project-tile” means it has both the classes “project” and “project-tile.”

2. Do portions of a class also become classes? For example, if I have a class="a b-c" , are both “a” and “b-c” classes then? Is “a b-c” also a 3rd class?

The classes here would be “a” and “b-c.” No 3rd class.

3. Or is this some way of trying to indicate a parent-child relationship where it’s being signified that “project-tile” is a child of “project”?

Nope, this is not a thing.

1 Like

Those are two separate classes for the same element. CSS will use both classes and apply them. If there is any conflict with the CSS, the latter class information will be applied.

1 Like