Solved

Applying multiple styles to one TD element

Posted on 2004-08-06
11
764 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
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 500 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
css, html 5 42
add image on html mail 6 19
Mouse event to control image and transparency. 4 22
Create an automated page index 9 16
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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