Reputation: 3247
I would like to know how I can set one setting for two different classes.
To give an example:
.footer #one .flag li .drop_down form div{
width: 80px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: left;
line-height: 1.5;
color: #ccc;
font-weight:bolder;
margin-left: 30px;
}
.footer #two .flag li .drop_down form div{
width: 80px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: left;
line-height: 1.5;
color: #ccc;
font-weight:bolder;
margin-left: 30px;
}
Both rules have the same content. The difference is just the second tag. Is there a way to do something like this?
.footer >>>#one and #two<<<< .flag li .drop_down form div{
width: 80px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: left;
line-height: 1.5;
color: #ccc;
font-weight:bolder;
margin-left: 30px;
}
Upvotes: 44
Views: 62960
Reputation: 29654
Separate with a comma:
.footer #one .flag li .drop_down form div,
.footer #two .flag li .drop_down form div
{
shared css
}
.footer #one .flag li .drop_down form div
{
css for element one only
}
.footer #two .flag li .drop_down form div
{
css for element two only
}
Upvotes: 2
Reputation: 583
.footer #one .flag li .drop_down form div,
.footer #two .flag li .drop_down form div{
...
}
Upvotes: 4
Reputation: 985
Use a comma instead of separate CSS rules:
.footer #one .flag li .drop_down form div,
.footer #two .flag li .drop_down form div {
width: 80px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: left;
line-height: 1.5;
color: #ccc;
font-weight:bolder;
margin-left: 30px;
}
Upvotes: 1
Reputation: 14412
In CSS you use a ,
(comma), unfortunately this is on the entire selector rather than just a section of it.
If you really wanted to make it cleaner you could give each of the form div's
a unique id and then just #form1, #form2
.
You can find further info in "Shorten the comma separated CSS selectors".
For example:
.footer #one .flag li .drop_down form div,
.footer #two .flag li .drop_down form div {
width: 80px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: left;
line-height: 1.5;
color: #ccc;
font-weight:bolder;
margin-left: 30px;
}
Upvotes: 8
Reputation: 165951
Separate the selectors with a comma:
.footer #one .flag li .drop_down form div,
.footer #two .flag li .drop_down form div {
/* Rules */
}
From the selectors level 3 spec:
A comma-separated list of selectors represents the union of all elements selected by each of the individual selectors in the list. (A comma is U+002C.) For example, in CSS when several selectors share the same declarations, they may be grouped into a comma-separated list. White space may appear before and/or after the comma.
Upvotes: 67