homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

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?




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

Have you tried
#sidebar #links
ul, #authors ul {...}

 9:39 pm on Apr 30, 2011 (gmt 0)

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)

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)

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>

The corresponding CSS would look something like this:

.links, .authors {


 7:04 am on May 3, 2011 (gmt 0)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved