1 reply [Last post]
Last seen: 14 years 8 weeks ago
Joined: 2004-04-23
Posts: 15
Points: 0

Hey all, definitely a newb on this forum. I've been using CSS on and off for about a year and a half now, and the same issue I've been running into time and time again is vertical alignment and tables.

Before CSS, I always used tables and the height = 100%. I then made a table within that table and left the width, height attributes set to whatever the table came out to be. That way the table was already centered vertically. Now, is there a way to do it in CSS?

From what I understand, there is a vertical-align attribute. I, however, don't know if it works with tables. I've read that it only works with table cells, images, and text. So that does me no good.

What I did do was the following:

<style type="text/css">
table.margined { margin: 12em }

Then I just set the table class = "margined" here's the result:


However, this is a pain because as people resize their browser, the table does not stay in the exact center of the browser.

Is there a way to have the table be vertically and horizontally centered in CSS?

Thanks all,

DCElliott's picture
Halifax, Canada
Last seen: 4 years 38 weeks ago
Halifax, Canada
Timezone: GMT-3
Joined: 2004-03-22
Posts: 828
Points: 0

Vertical aligning a table

I just happen to have an example and some discussion I had prepared for a similar question on another forum. So if you don't mind recycled goods :roll: I hope this helps.


David Elliott

Before you ask