2

I have two css expressions:

.firstexpression.secondexpression (without space)

and

.firstexpression .secondexpression (with space)

What is the difference?

Lewis
  • 789
  • 8
  • 20
Tuvia Khusid
  • 792
  • 5
  • 15
  • 31
  • See: http://stackoverflow.com/questions/10036156/whats-the-difference-between-css-classes-foo-bar-without-space-and-foo-bar, http://stackoverflow.com/questions/1126338/difference-between-classa-classb-and-classa-classb-in-css, http://stackoverflow.com/questions/14763313/whats-the-difference-between-these-two-css-selectors?rq=1 – Josh Crozier May 14 '14 at 17:18

1 Answers1

7

The first applies to elements with BOTH classes applied, the second to a child element with .secondexpression with a parent with .firstexpression

.firstexpression.secondexpression{
   /* styles */
}

Applies to:

<div class='firstexpression secondexpression'>Applies to this element</div>

Vs..

.firstexpression .secondexpression{
   /* styles */
}

Applies to:

<div class='firstexpression'>
   <div class='secondexpression'>Applies to this element only</div>
</div>
SW4
  • 69,876
  • 20
  • 132
  • 137