Reputation: 337
I understand that a space between CSS selectors indicates nesting. For example, .funny p would select all paragraph elements within an element of the class "funny", and I would similarly (from this logic) expect div .funny to select all "funny" elements within a div tag. However, I never actually see nested selectors in that form in any documented examples, but see quite a bit of those in the form div.funny. Is this simply nice shorthand for what div. funny would convey, or is there in fact a subtle difference I'm missing here? Thanks!
Upvotes: 0
Views: 882
Reputation: 673
div.funny
in CSS would target a div
with the class name of funny
, which is also what you'd get if you were to use that as a jQuery selector.
Upvotes: -1
Reputation: 207861
div.funny
Selects all divs that have the class funny
While
div .funny
Selects all elements with the class funny
that are descendants of a div.
The space makes a significant difference
Upvotes: 5