Welcome to WebmasterWorld Guest from 54.163.68.15

Forum Moderators: not2easy

Message Too Old, No Replies

Declare multiple IDs

   
1:45 am on Apr 30, 2011 (gmt 0)



This has got to be easy, but I can't quite seem to get it right and I can't find anything online to help out.

Here is my sample CSS

#sidebar #links ul {
...
}

#sidebar #authors ul {
...
}

However the CSS declared for each ul is the same. So I'd like to merge that into one piece of CSS like this

#sidebar #links, #authors ul {
...
}

But that doesn't work!

Anyone know what the correct syntax is?

JB
5:11 am on Apr 30, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Have you tried
#sidebar #links ul, #authors ul {...}
9:39 pm on Apr 30, 2011 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Since ID's are unique, it's overkill to have more than 1 ID within a selector. #sidebar can be removed entirely, unless it's being used to increase specificity. Here's how you could combine them:

#links ul,
#authors ul {
...
}
9:40 pm on Apr 30, 2011 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



If you need to keep the #sidebar for specificity reasons, then it would be this:

#sidebar #links ul,
#sidebar #authors ul {
...
}
3:25 am on May 3, 2011 (gmt 0)

5+ Year Member



I suggest you stay away from ID's within the selctor (like Fotiman).

I would add classes to the UL tag.

<div id="sidebar">
<ul class="links">...</ul>
<ul class="authors">...</ul>
</div>

The corresponding CSS would look something like this:

.links, .authors {
...
}
7:04 am on May 3, 2011 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



what would be wrong with:
#sidebar ul{ ...