Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
How do you get a table to stay centered on the page?
Old 05-30-2009, 01:42 AM How do you get a table to stay centered on the page?
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
I'm talking about the still respected kind of table: the one with tabular data.

I have three of such tables on a website I'm building.

One stays in the center, the others slide to the left, even though I wrote in the CSS:

Code:
#main {
text-align: center;
}
HTML and CSS passes validation without error, I even filled empty table cells with " ".

The one table that respects the align: center; is the one with no empty table cells. the other two have one empty <th> each. Putting in "&nbsp;" doesn't help.

Do I have to give the tables a class, and then put the text-align: center; right into the CSS of this class?

Is there something about tables that stays in the shadow from my searching eyes?
World is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-30-2009, 12:52 PM Re: How do you get a table to stay centered on the page?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
The text-align: center will only center the data inside the table. If you give the table a width, you can use the margin: 0 auto; method to center it.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-30-2009, 10:40 PM Re: How do you get a table to stay centered on the page?
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
Thanks, lady!

I'll give all tables a class and handle it so with the CSS.
World is offline
Reply With Quote
View Public Profile
 
Old 06-06-2009, 11:55 PM Re: How do you get a table to stay centered on the page?
Novice Talker

Posts: 4
Name: Lee Jacobson
Trades: 0
The way I do it is to use css and do:
table#id{
margin-left:auto;
margin-right:auto;
}
leejw00t354 is offline
Reply With Quote
View Public Profile
 
Old 06-07-2009, 11:21 AM Re: How do you get a table to stay centered on the page?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
You still have to define a width to make that work.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How do you get a table to stay centered on the page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.05774 seconds with 12 queries