View Full Version : Table Attribute II
cg9com
11-21-2002, 04:00 PM
How can i center align a <table> ?
align="center" wont validate in xhtml10 strict
MCookie
11-21-2002, 08:16 PM
To center a table..
table {
width:80%;
margin:0px 10%;
}
Or:
table {
margin-left:auto;
margin-right:auto;
}
But Win/IE5 doesn't understand 'auto'. You need a workaround:
body {
text-align:center;
}
table {
margin-left:auto;
margin-right:auto;
text-align:left; /* to compensate for the text-align:center */
}
cg9com
11-21-2002, 08:28 PM
Originally posted by MCookie
table {
width:80%;
margin:0px 10%;
}
thanks alot for the help, but whats the significance of having the width there?
is this basically a method of not centering the table, but through margins and size, forcing it to the center?
MCookie
11-21-2002, 08:39 PM
Yes, it centers the table without centering it.. You could also use this:
table {
width:80%;
margin:0px auto;
}
but Win/IE5 doesn't understand 'auto'. That's why I used the 10% margins.
cg9com
11-21-2002, 08:49 PM
ok :)
thanks alot man.
xhtml strict can be tricky
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.