homepage Welcome to WebmasterWorld Guest from 184.73.104.82
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
johnblack



 
Msg#: 4306201 posted 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

 

alt131

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4306201 posted 5:11 am on Apr 30, 2011 (gmt 0)

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

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4306201 posted 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 {
...
}

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4306201 posted 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 {
...
}

jabz

5+ Year Member



 
Msg#: 4306201 posted 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>
</div>

The corresponding CSS would look something like this:

.links, .authors {
...
}

topr8

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



 
Msg#: 4306201 posted 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