user1761494
user1761494

Reputation: 125

Multiple classes + ID's in CSS do the same?

You know in Java/PHP you can do something like this:

if (c.bigX == 1 || c.smallX == 2 || c.mediumX == 6) {
something here
}

How can I make it with CSS?

I have 5 classes, and I want them to do the same thing. instead of making a lot of lines. Thanks

Upvotes: 1

Views: 164

Answers (3)

William de Castro
William de Castro

Reputation: 86

.class1, .class2, .class3, .class4, .class5 {
  property:value;
}

This will help

Upvotes: 0

Chowlett
Chowlett

Reputation: 46675

Use commas in your selector:

.class1, .class2, .class3 {}

Bear in mind that each clause in such a list is a complete selector in its own right; that is

div .class1, .class2 {}

matches class1 descendants of divs; and all .class2 elements. If you wanted class1 or class2 descendants of divs, you need:

div .class1, div .class2 {}

Upvotes: 0

Morpheus
Morpheus

Reputation: 9075

Like this:

.class1, .class2, .class3 {} etc.

Upvotes: 6

Related Questions