CSS Horizontal Align

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

CSS Horizontal Align

Post by php_wiz_kid »

What's the CSS attribute for horizontal align in for the table element?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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.
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

I'll just stick with align="center", thanks.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

object {
text-align: center;
}

style="text-align: center;"
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post 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.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Code: Select all

table &#123; text-align: center; &#125;
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Stick a div around the table:

Code: Select all

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