Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1px vs thin, IE vs Excel issues

I have an html table which is rendered in IE, and Excel (for reporting)

If I set the border-width to thin, it shows a 2px border in IE, and a 1px border in Excel.

However, if I set it to 1px, it shows a 1px border in IE, and a 2px border in Excel(???).

How can I get them to BOTH show a 1px border as it looks horrible with a 2px border.

like image 495
CaffGeek Avatar asked Jul 21 '11 17:07

CaffGeek


People also ask

Can a border be smaller than 1px?

The minimum width that your screen can display is 1 pixel. So its impossible to display less then 1px. 1 pixels can only have 1 color and cannot be split up.

How do you reduce a border in HTML?

Adjusting the Margin Size of an HTML Element With CSS You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .


2 Answers

Saving a excel file to html genrates CSS like so:

.xl32
{mso-style-parent:style0;
border-top:.5pt solid windowtext;
border-right:1.0pt solid windowtext;
border-bottom:1.0pt solid windowtext;
border-left:.5pt solid windowtext;}

.5 displays as a normal line, 1.0 as a thick line So i guess setting te with to .5pt should work...

like image 50
Arnoud Kooi Avatar answered Sep 22 '22 13:09

Arnoud Kooi


I don't know anything about HTML Tables rendered in Excel. I'm curious if it uses IE rendering engine, or some custom rendering engine. (It sounds like it might use a custom one, based on the differences.)

One thing you could try is setting the border to 'thin', and then having a separate CSS rule inside a Conditional IE statement. See QuirksMode.org for more information on IE Conditionals.

So it could be:

<style>
   table { border: thin solid black; }
</style>

<!--[if lt IE 9]>
<style>
   table { border: 1px solid black; }
</style>
<![endif]-->
like image 27
Bryan Avatar answered Sep 23 '22 13:09

Bryan