Previous Message
Next Message

Style rule based upon ID and Class?

Sent by Steve Clason on 14 May 2005 23:11


On 5/14/2005 3:05 PM Jeff Chastain wrote:
> Maybe a dumb question, but is it possible and if so, what would it look like
> to write a style rule that is based upon the combination of an id and class
> value on one tag?  For example, I would like to see the following two tags
> styled differently ...
>  
> <div id="explorer" class="mini"></div>
>  
> <div id="explorer" class="full"></div>
>  
> Is this possible, or do I just need to skip the ID and make two different
> classes (miniExplorer and fullExplorer)?  I would like to do it as above so
> that some shared styles could be done based upon the ID and the differences
> between the two divs could be done based upon the class.

I do it all the time, but I think you have it a little backwards. Since 
you shouldn't repeat ids (really, just don't), you should include the 
common features in classes, then the unique styles in the id.

So:

<div class="explorer" id="mini">Mini</div>
<div class="explorer" id="full">Full</div>

and

..explorer{
   border: 1px solid #000;
   background-color: #ccc;
   color: #000
   padding 1ex;
}

then

#mini{
   font-weight: normal;
}
#full{
   font-weight: bold;


Both "Mini" and "Full" will be black text on a gray background 
surrounded by a 1 px solid black border. "Mini" will be normal--"Full" 
will be bold.


-- 
Steve Clason
Web Design and Development
Boulder, Colorado, USA
www.topdogstrategy.com
(303)818-8590

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: