Ellbar
Ellbar

Reputation: 4054

Select elements with specific class in specific div

Lets say I have a div with class DIVCLASS, and I have elements with class ELEMENTCLASS. How can I select all elements with class: ELEMENTCLASS that are in divs with class: DIVCLASS?

Upvotes: 0

Views: 147

Answers (2)

ThomasM
ThomasM

Reputation: 2677

Depends,

Does it matter at which level ELEMENTCLASS is situated in DIVCLASS?

If not, use:

.divclass .elementclass {
    //properties here
}

If you only want to select ELEMENTCLASS that are direct descendants of DIVCLASS, use:

.divclass > .elementclass {
    //properties here
}

Don't overspecify by using div.divclass unless it's really necessary.

Upvotes: 2

emerson.marini
emerson.marini

Reputation: 9348

div.divclass > .elementclass

Upvotes: 1

Related Questions