Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applying multiple styles to one TD element

Posted on 2004-08-06
11
Medium Priority
?
792 Views
Last Modified: 2011-04-14
First off, this might sound like a strange question but bear in mind that the HTML is being dynamically generated and this is why I need to do it this way...

I have TD elements e.g. <TD class=format1>

The problem is that my TD.format1 style does not define any borders, just fonts and colors and indenting and such. I do not want to put border information in the format1 style.

I also want to apply borders to the TD.

Right now I am doing it this way: <TD class=format1 style='border-left: solid 1pt #3366ff; border-right: solid 2pt #66DDFF; border-top: dotted 3pt #FFCCEE;'>

as you can see this is very verbose... if I'm going to have many tens or hundreds of thousands of TDs then this adds much size to the file.

My understanding is that CSS does not allow something like this: class=format1,border1 . If it did support this then that would be ideal since I have a limited number of border styles and can construct a <STYLE>...</STYLE> listing all of them.

Can anyone think of a way to do what I want to do in a less verbose manner?
0
Comment
Question by:ycomp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 2000 total points
ID: 11739958
Hi

Actually it is allowed: For example,

<style type="text/css">
.border1 {border:2px solid red;}
.format1 {font-size:24pt;}
</style>

<td class="format1 border1">HEHEHEHEHEHE</td>

Regards,
Zyloch
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11739965
P.S. And I owe knowing this all to Sean. I say thanks to the almighty one who knows 200+ times more than I in CSS and layout

Regards
0
 

Author Comment

by:ycomp
ID: 11739973
for some reason I thought I read somewhere it wasn't allowed. my memory is not the best though. perhaps maybe that was a CSS limitation?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ycomp
ID: 11739977
CSS 1 limitation I mean
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11740009
I'm not quite sure, sean will probably know, but it is official CSS as far as I know and is pretty widely supported:

http://www.w3.org/TR/html401/struct/global.html#adef-class
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 11740057
http:#11739958

Perfect.
0
 
LVL 2

Expert Comment

by:Joakim_
ID: 11741134
This is allowed by W3C. Just go ahead and use it.
0
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 11742540
thats interesting.
0
 

Expert Comment

by:NanZhong
ID: 11747865
Another way to do it would be giving the td both an id and a class.

Eg. <td id="id1" class="class1">

Then in the css just give #id1 and .class1 whatever styling you want.

Eg.

#id1 {border:2px solid red;}
.class1 {font-size:24pt;}
0
 
LVL 2

Expert Comment

by:Joakim_
ID: 11748436
That's a stupid solution. IDs have to be unique, and is meant to be used to give elements a unique ID. Either add two class names in the CLASS-tag, or make one class with the style.
0
 

Author Comment

by:ycomp
ID: 11749013
yes 2 class names works. I just thought it was illegal for some reason. IDs are not a solution for me.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question