Page 1 of 1
ccs table align.....
Posted: Fri Dec 05, 2003 4:50 pm
by gavinbsocom
How would I align a table in css? I dont want to do it in the html document itself? I know you can use
Code: Select all
table.head
{
align: center; ???
}
Posted: Fri Dec 05, 2003 4:55 pm
by microthick
If you are trying to center a table, there are two ways:
1) Auto-Width Margins:
http://bluerobot.com/web/css/center1.html
2) Negative Margin:
http://bluerobot.com/web/css/center2.html
It's harder than it should be due to problems with IE and how it interprets the css.
Posted: Mon Dec 08, 2003 3:11 am
by twigletmac
If memory serves, one way of aligning a table which works in both IE and Gecko browsers is to add a little hack for IE, a div tag with an text-align: center style:
Code: Select all
<div style="text-align: center">
<table style="margin: 0 auto;>
<!-- more table tags -->
</table>
</div>
Mac
Posted: Sun Dec 14, 2003 10:09 am
by Fredix
For me
Code: Select all
table
{
maring-left:auto;
margin-right:auto;
}
alsways worked out as long as table is not positioned absolutely.
This method is also W3C correct.
Posted: Tue Dec 23, 2003 7:51 pm
by Skyzyx
Setting margin-left:auto and margin-right:auto only works when the width is explicitly set.
Code: Select all
table {
margin:0 auto 0 auto;
width:500px;
}
Also, you can center an element by making a container, and setting text-align:center to that container.
Code: Select all
<div style="text-align:center;">
<table>
<tr>
...
</tr>
</table>
</div>