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

    
Multiple CSS classes
Can it be done
Filipe




msg:1221875
 5:37 pm on May 15, 2002 (gmt 0)

Is it possible to assign multiple classes to a single element? Let's say I had a class just for centering things:

.centered {text-align: center;}

and one (let's call it class2) for other style type stuff (let's say I wanted to apply this second class to text, but I didn't necessarily want it all centered).

Could I do something like:

<div class="centered,class2">
text
</div>?

 

pcguru333




msg:1221876
 6:09 pm on May 15, 2002 (gmt 0)

I have done it successfully

I use this format

<div class="class1 class2">

Filipe




msg:1221877
 6:18 pm on May 15, 2002 (gmt 0)

Is this supported across browsers?

pcguru333




msg:1221878
 6:42 pm on May 15, 2002 (gmt 0)

Good question, I don't know if it is supported in Netscape.

I have tested it in IE 5,6 and Opera 6.

AlbinoRhyno




msg:1221879
 10:55 pm on May 15, 2002 (gmt 0)

Although I am not an authority, I would think that it is not well-formed syntax. Try using

<div class="class1">
<div class="class2">
class1/class2 text or whatnot
</div>
</div>

Not sure. Try running your double class file through a validator.

papabaer




msg:1221880
 1:31 am on May 16, 2002 (gmt 0)

What I use is the ID & .class 1,2 combo...
<head>
<style type="text/css" media="all">
#div-one {
position:absolute;
top:0;
left:0;
width:100%;
height:auto;
padding:0 10px;
border:1px solid #900;
}

#footer {
padding:20px 10px;
text-align:center;
}

#new-news {
float:left;
width:200px;
height:auto;
border:3px solid #000;
}

.redfont {
font:12px/16px georgia, palatino, serif;
color:#c00;
background:#fff;
}

.small-font;
font:10px/13px;
color:#009
bacground:#ccc;
}
</style>

Positioning can be applied to the unique elements while the actual style of the content may be applied using a general class statement.

<div id="new-news" class="redfont"></div>

- papabaer

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