Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css multiple class / id selectors?

I'd like to know how to write a css block that applies to either multiple ids or multiple classes:

Something like:

.class1, .class2 {  ... } 

or

#id1, #id2 {  ... } 

I'd like to know how to do both cases (which hopefully are cross browser compliant). Thanks.

Update: To make it more interesting, is this valid too?

#id tr, #id2 tr {  } 

?

like image 406
aeq Avatar asked Aug 11 '10 12:08

aeq


People also ask

Can I select multiple classes in CSS?

We aren't limited to only two here, we can combine as many classes and IDs into a single selector as we want.

How do you select multiple classes in HTML?

To do this, start with the element name, then write the period (.) character, followed by the name of the class (look at Example 1 below). HTML elements can also refer to more than one class (look at Example 2 below).


1 Answers

You are looking for something like this :

.oddBoxOut,  .evenBoxOut {   width: 12em;   padding: 0.5em;   margin: 0.5em;   border: solid 1px black; }  .oddBoxOut {   float: left; }  .evenBoxOut {   float: right; } 

Update :

p#exampleID1 { background-color: blue; }  p#exampleID2 { text-transform: uppercase; } 
like image 133
Pranay Rana Avatar answered Sep 20 '22 22:09

Pranay Rana