We help IT Professionals succeed at work.

space between selectors and classes

designaire
designaire asked
on
Just a general question. What is the different when you group classes or selctors if you have a space between them or not.
#main .sidebar

#main.sidebar
Comment
Watch Question

Unless someone knows anything different:

#main.sidebar will only apply to the element with id="main"

i.e.
<div id="main" class="sidebar">
  <div>Test</div>
</div>

Open in new window


whereas #main .sidebar will apply to an element within #main

ie.
<div id="main">
  <div class="sidebar">Test</div>
</div>

Open in new window