TL;DR
The easiest way to center content both vertically and horizontally is with a one-row, one-column table. In DreamWeaver, set the table to 100 percent width with zero border, padding, and spacing, add height=100% in the code, then set the cell's Horz to center and Vert to middle.
- Adding height=100% right after width="100%" makes the table span the entire height of the screen as well as the width.
- Putting some text in the table first, like Don't Lick the Purple Cow!, gives you something to test with while you work.
- This comes in handy when designing for multiple resolutions or centering a simple Flash movie in the middle of a page. DreamWeaver MX 2004 needs one extra step.
This is an archived tutorial from the kirupa.com legacy collection. It covers software that may no longer be available, but it is kept online because the ideas still hold up.
Recently, many people have been asking how
they can center things both vertically and horizontally in
their web pages. The easiest way to accomplish this is with
tables. This tutorial will be directed towards DreamWeaver
users, but the code should also work in FrontPage as well as
any other website editor you happen to use.
OK, let’s get started!
-
First, you will need to create a new
document. Do this by going to File | New and select Basic
Page in the left-hand column and HTML in the right-hand
column. Then click create.
-
Now, we will create our table. To do this, go to Insert |
Table.
-
For this tutorial, we will create a table with one row and
one column. To do this, replace the default values to the
right of “rows” and “columns”.
You will need to set your table width to 100, and then in the drop down menu, select percent. Also, set “border thickness”, “cell padding”, and “cell spacing” to 0:

[ adjust your table properties ]
-
When you have done all of this, click OK.
-
Now, since DreamWeaver doesn’t give a built in option in
the box that was just open, we will have to edit the code
a little bit.
The first thing we will do is put some text in the table so that we can test while we work. To do this enter some random stuff in the coding part of DreamWeaver, where it says, “ ”. I will enter, “Don’t Lick the Purple Cow!”
Now, we will edit the table itself.
-
What we are going to do is make the table span the entire
height of the screen, as well as the entire width. Put
your cursor after your code says
width=“100%”. Insert a space (by pressing the space bar, duh…). Now enter the following code:height=100%.
-
Click down into the design area, the dotted line
surrounding your table will have expanded to the entire
area of the panel.
Next, click in the table in your design area. You should see your properties panel change to have almost all of the properties of your table.
You will only need to change two things here. Set “Horz” to “center”, and set “Vert” to “middle”. Now you’re done!
|
|
Note |
|
In DreamWeaver MX 2004, there is one
more step. Go to this
thread to learn more.
|
|
Your text should be nicely centered in the design area. This can come in handy when designing websites for multiple resolutions, or just plain for the sake of centering a simple flash movie in the middle of a page. If you have any questions, feel free to post on the forum.
Thanks,
| External resource (archived resource unavailable) | Brad aka Yeldarb |
Before you go, here are a few things you can do:
-
Keep reading
Read the next article in the series, Web Tricks, or check out some related content:
-
Ask a question
Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy kirupa's books, became a paid subscriber, watch the videos, and/or interact on the forums.
Your support keeps this site going! 😇
