 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Gnomeface
Joined: 04 Nov 2009 Posts: 3
|
Posted: Wed Nov 04, 2009 2:13 am <col> not working fully in IE8 |
|
|
|
First post - sorry if it's been covered before (I did search!).
I have a large table of data (10 columns x 200-300 rows) where I use different text colours for each column. This has worked fine in the past using <col>, e.g. the following 2 lines at the start of the table:
<table align="center" cellspacing="0" frame="box" rules="all">
<col span="3" style="color:blue;"><col span="2" style="color:green;">... etc.
In IE8 this does not work - IE8 appears to ignore the style element, unlike IE7. In "compatibility mode" the colours reappear and all is well - but the users of my site are not sufficiently computer literate to be able to reset their browser.
Is there any easy alternative coding to make these colours work again in natural IE8? I'm an amateur coder without huge knowledge of HTML.
I notice that the example given on this very site, at
http://www.htmlcodetutorial.com/tables/_COL.html
also fails to work unless compatibility mode is switched on!!!
Thanks for any help. |
|
sticks464

Joined: 31 Dec 2006 Posts: 2627
|
Posted: Wed Nov 04, 2009 5:16 am |
|
|
|
The W3C specifies that only a few declarations may be used on columns: border, background, width and visibility.
Exception: IE7 and lower allow all declarations.
The alternative is to apply a style directly to each <td> with the use of the class attribute. This works for all browsers and over rides the col style.
Using the link http://www.htmlcodetutorial.com/tables/_COL.html it has to be done as follows for IE8 to display correctly.
| Code: |
<style type="text/css">
.red {color:#f00;}
</style> |
| Code: |
<TABLE BORDER CELLPADDING=5>
<COL>
<COL ALIGN=RIGHT>
<COL>
<TR> <TH>Expense</TH> <TH>Price</TH> <TH class="red">Status</TH> </TR>
<TR> <TD>office suite</TD> <TD>1,343.56</TD> <TD class="red">rental</TD> </TR>
<TR> <TD>cabling</TD> <TD>1.25</TD> <TD class="red">installed</TD> </TR>
</TABLE> |
This may not be the answer your looking for when talking about 200 - 300 rows, but AFAIK it is the only way for IE8. |
|
Gnomeface
Joined: 04 Nov 2009 Posts: 3
|
Posted: Wed Nov 04, 2009 10:36 am <col> in IE8 |
|
|
|
Thanks for the prompt and useful reply, and the explanation of what initially seemed to be a backward step by Microsoft.
You have offered a very clear example and I'll alter my code to handle the colours using classes. In fact I generate the HTML code using formulae within an Excel spreadsheet, so it is a fairly simple task to change the formulae - my concern was that it might result in an excessively large html file, but this shouldn't now be the case.
Now it just needs someone to rewrite the <col> example page on this site! |
|
sticks464

Joined: 31 Dec 2006 Posts: 2627
|
Posted: Wed Nov 04, 2009 11:14 am |
|
|
|
| Sorry, I'm not in charge of re-doing the tutorials here. |
|
Gnomeface
Joined: 04 Nov 2009 Posts: 3
|
Posted: Wed Nov 04, 2009 11:34 am <col> without Style |
|
|
|
OK, spreadsheet formulae modified and the whole table works just fine now - the generated HTML file has grown from 35K to 56K but that's not a problem.
Thanks once again. |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|