3 replies [Last post]
pet110
Offline
newbie
Last seen: 15 years 38 weeks ago
Joined: 2005-03-11
Posts: 7
Points: 0

Hi,
i'm searching for an valid and working possibility to have two styles applied to one element.
i'm working on a dynamic page, where i want to switch the color on a lot of element-styles.

i don't want to write the hole definition for .div1 or .div2 for 10 different colors.

thanks
peter

short example(works, but not valid, because of more than one element with id "color1"...)

.div1{
	float: left;
	height: 40px;
	margin-left:0px;
	margin-right: 0px;
	border-bottom: 0px solid #AAAAAA;
	border-right: 2px solid #AAAAAA;}
.div2{
	float: left;
	height: 40px;
	margin-left:0px;
	margin-right: 0px;
	border-bottom: 0px solid #AAAAAA;
	border-right: 2px solid #AAAAAA;}
#color1{background: #FFFFFF url(/images/bg/E2E8F5.gif);}    
#color2{background: #FFFFFF url(/images/bg/B5C4E4.gif);}  

<div class="div1" id=color1>test</div> 
<div class="div2" id=color1>test</div> 

<div class="div1" id=color2>test</div> 
<div class="div2" id=color2>test</div> 

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 36 weeks 4 days ago
Joined: 2004-06-30
Posts: 9668
Points: 801

2 style attributes on one element?

You can't use #id more thann once. . . change to a .class and you'll be fine Laughing out loud

Verschwindende wrote:
  • CSS doesn't make pies

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 8 years 10 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

2 style attributes on one element?

to elaborate a little on TPH's wise words Smile

You can have more than one class on an element.

<div class='div1 color1'>...
<div class='div2 color2'>...
<div class='div1 color3'>...

pet110
Offline
newbie
Last seen: 15 years 38 weeks ago
Joined: 2005-03-11
Posts: 7
Points: 0

2 style attributes on one element?

thanks for the increddible fast answers...

i tryed the use of two class attributes, but perhaps because of a syntax-problem it didn't worked before

now its working and i'm happy

peter