Welcome to WebmasterWorld Guest from 23.23.46.20

Forum Moderators: not2easy

Multiple CSS classes

Can it be done

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

10+ Year Member



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>?

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

10+ Year Member



I have done it successfully

I use this format

<div class="class1 class2">

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

10+ Year Member



Is this supported across browsers?
6:42 pm on May 15, 2002 (gmt 0)

10+ Year Member



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

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

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

10+ Year Member



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.

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

WebmasterWorld Senior Member 10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month