Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the actual width of default table borders?

When you use a table tag and add border="1", what is the actual value of that border? It's not 1 pixel because when I try to replicate it's much thinner than the border=1 version. So:

"border=1" is a thicker line

style="border:1px solid #000" is a thinner line

I am trying to replicate it but can't find a match.

EDIT: I need to do this inline as there will not be a style sheet. Please let me know if this can be done inline at all.

like image 500
Rachel S Avatar asked Sep 06 '25 07:09

Rachel S


1 Answers

The difference between the border attribute and the style attribute is that the former also gives borders to the cells inside, while the latter doesn't.

So that got me thinking, and my guess is that you haven't given all the information needed to replicate the problem. So please correct me if I'm wrong, but I am assuming that you also had cellspacing="0" on the table, and in the attempted styled version, no style attribute on the table cells.

<table border="1" cellspacing="0">
<tr><td>with border attr</td></tr>
</table>

<br>

<table style="border:1px solid #000">
<tr><td>with style props</td></tr>
</table>

So in the top table, the table has a 1px border, and the cell inside also does. And there you have it, 2px border in total.

This situation can be emulated using styles; you just need some more styles.

<table border="1" cellspacing="0"> <!-- same as above -->
<tr><td>with border attr</td></tr>
</table>

<br>

<table style="border:1px outset #000; border-spacing:0">
<tr><td style="border:1px inset #000">with style props</td></tr>
</table>
like image 170
Mr Lister Avatar answered Sep 10 '25 05:09

Mr Lister