-4

I have realized that the css selector

"#id.classname" 

vs

"#id .classname"

is not the same. See the whitespace in the 2nd sample.

What is the difference between those two?

I thought both mean a class applied to an element with that id.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Elisabeth
  • 20,496
  • 52
  • 200
  • 321

1 Answers1

5

The whitespace makes a huge difference because it is the descendant selector combinator.

The first selector applies to an element with id id that has the class classname.

The second applies to an element that has the class classname which is also a descendant of the element with id id.

Jon
  • 428,835
  • 81
  • 738
  • 806