navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Table Center

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets >> Table Center
Page: [1]
 
Chugachman

 

Posts: 63
Joined: 2/8/2004
From: Alaska
Status: offline

 
Table Center - 12/26/2004 4:15:29   
What is the correct syntax in CSS so that a table is centered on the page.

Much obliged...happy holidays!
d a v e

 

Posts: 4166
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Table Center - 12/26/2004 6:06:22   
this
http://members.tiscali.fi/dave_pirjo/test-area/css_stuff/table_centred.htm
basically to centre a block level element such as a table use
margin:0 auto;


it won't work in IE if you use a transitional doctype (then you have to use the center attribute on the table element) but if you're using strcit (x)html it works fine., but that's just cos IE is crap.

_____________________________

David Prescott
Gekko web design

(in reply to Chugachman)
Chugachman

 

Posts: 63
Joined: 2/8/2004
From: Alaska
Status: offline

 
RE: Table Center - 12/26/2004 13:03:40   
I'm sorry, I didn't communicate well.

What would I write on a CSS style sheet so that all tables are centered on the page. I can't find it in any of my reference books.

Thanks!

(in reply to d a v e)
Donkey

 

Posts: 3909
Joined: 11/13/2001
From: Blackfield United Kingdom
Status: offline

 
RE: Table Center - 12/26/2004 18:49:57   
Use what Dave gave you above as the declaration and table as the selector;

table{margin:0 auto;}


_____________________________

:)

I have a higher and grander standard of principle than George Washington. He could not lie; I can, but I won't.
Samuel Clemens

(in reply to Chugachman)
Giomanach

 

Posts: 6128
Joined: 11/19/2003
From: England
Status: offline

 
RE: Table Center - 12/26/2004 21:15:35   
quote:

it won't work in IE if you use a transitional doctype (then you have to use the center attribute on the table element) but if you're using strcit (x)html it works fine., but that's just cos IE is crap.

A bit more CSS will solve that bug...

CSS:

html, body{
text-align: center;
}

#page{
margin: 0 auto;
width: 775px;
text-align: center;
}

HTML:

<html>
<head>
<title>Page 1</title>
<link type="text/css" rel="stylesheet" href="01.css">
</head>
<body>
<div id="page">
<table>
....Table coding..rows, cells etc....
</table>
</div>
</body>
</html>

works in all browsers without fail =)

_____________________________




(in reply to Donkey)
d a v e

 

Posts: 4166
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Table Center - 12/28/2004 16:09:37   
but you would have to remember to explicitly set any descendants of html, body, #page as left aligned unless you wanted those centred too - probably!

_____________________________

David Prescott
Gekko web design

(in reply to Giomanach)
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets >> Table Center
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts