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 { }
?
We aren't limited to only two here, we can combine as many classes and IDs into a single selector as we want.
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).
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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With