Page 1 of 1

CSS Horizontal Align

Posted: Fri Sep 26, 2003 11:38 am
by php_wiz_kid
What's the CSS attribute for horizontal align in for the table element?

Posted: Fri Sep 26, 2003 11:59 am
by microthick
I'm not sure there's a specific attribute for horizontal alignment to replace the align="center" attribute that html has for tables.

Your best bet is probably to wrap the table in a <div> and then style the div with <div style="display: block; float: center;" ...>.

Of course, if you're simply wanting to set horizontal alignment for a table cell, that's just text-align: center.

Posted: Fri Sep 26, 2003 12:05 pm
by php_wiz_kid
I'll just stick with align="center", thanks.

Posted: Sat Sep 27, 2003 5:41 pm
by nigma
What do you mean horizontal align a table element?

You mean you want to do this in CSS:

Code: Select all

<table>
<tr><td align="center">Centered</td></tr>
</table>
If not please say soemthing, I am sure I can help you out.

Posted: Sat Sep 27, 2003 6:56 pm
by Cruzado_Mainfrm
object {
text-align: center;
}

style="text-align: center;"

Posted: Sat Sep 27, 2003 10:19 pm
by php_wiz_kid
No no no, I want to center the table in the web page, so the code in HTML would be

<table align="center">

not the text or a cell. Thanks for helping guys. I appriciate it.

Posted: Sat Sep 27, 2003 11:40 pm
by nigma

Code: Select all

table &#123; text-align: center; &#125;

Posted: Sat Sep 27, 2003 11:43 pm
by Nay
php_wiz_kid wrote:No no no, I want to center the table in the web page, so the code in HTML would be

<table align="center">

not the text or a cell. Thanks for helping guys. I appriciate it.
Text or not, it aligns into the center ;).

-Nay

Posted: Sun Sep 28, 2003 12:04 am
by nigma

Code: Select all

table &#123; text-align: center; &#125;
This should only align the table to center, not text in table, if it aligns the text in table do:

Code: Select all

table td &#123; text-align: left; &#125;
And in mozilla for some reason that won't align table to center, you have to do <table align="center">; <table style="text-align: center"> might also work, but not sure.

Posted: Mon Sep 29, 2003 3:22 am
by twigletmac
Stick a div around the table:

Code: Select all

<div style="text-align: center;">
<table>
...
</table>
</div>
Mac