# Centering Website

**URL:** <https://boards.straightdope.com/t/centering-website/440434>\
**Category:** Factual Questions\
**Created:** [March 7, 2008, 1:31pm UTC](https://boards.straightdope.com/t/centering-website/440434 "2008-03-07T13:31:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SharkB8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@SharkB8](https://boards.straightdope.com/u/SharkB8)\
**Post date:** [March 7, 2008, 1:31pm UTC](https://boards.straightdope.com/t/centering-website/440434/1 "2008-03-07T13:31:26Z")

</div>

Top o’ the mornin’.

I am in no way html/website savvy, but I bought Dreamweaver and “Dreamweaver For Dummies” and have built a website sufficient and pretty enough for our business, but I cannot, for the life of me figure out how to make it so that the body of the website is centered, no matter the size of the monitor on which the website is viewed. Kinda like now, this message board is centered on my screen. And would be centered on any screen viewing it, there isn’t a lot of extra space on one side of the screen or anything.

I’ve gone to a few trouble shooting sites and followed the directions I’ve read, but no luck.

Also, not sure if this matters, but I’m using a Mac.

Oh, and it’s Dreamweaver 8.

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [March 7, 2008, 1:39pm UTC](https://boards.straightdope.com/t/centering-website/440434/2 "2008-03-07T13:39:51Z")

</div>

Don’t you just wrap the content with \<DIV ALIGN=“center”\>\</DIV\> tags?

---

<div class="post-metadata">

**Author:** ![SharkB8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@SharkB8](https://boards.straightdope.com/u/SharkB8)\
**Post date:** [March 7, 2008, 1:51pm UTC](https://boards.straightdope.com/t/centering-website/440434/3 "2008-03-07T13:51:20Z")

</div>

[QUOTE=Mangetout]  
Don’t you just wrap the content with \<DIV ALIGN=“center”\>\</DIV\> tags?  
[/QUOTE]

Yeah…no?

Again, EXTREMELY not html smart…

But I will try that! Thanks!

---

<div class="post-metadata">

**Author:** ![kushiel](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kushiel](https://boards.straightdope.com/u/kushiel)\
**Post date:** [March 7, 2008, 1:59pm UTC](https://boards.straightdope.com/t/centering-website/440434/4 "2008-03-07T13:59:42Z")

</div>

Did you build in in tables, or divs with CSS?

If it is in tables, put an align=“center” on the table tag wrapping around all the content.

If it is using divs and CSS, it’s more complicated. I have to run to work, but [this site](http://tutorials.alsacreations.com/centrer/) explains how to do it. I’m sure another Doper (or myself) can check back if you’re still having problems. 😉

---

<div class="post-metadata">

**Author:** ![anson2995](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@anson2995](https://boards.straightdope.com/u/anson2995)\
**Post date:** [March 7, 2008, 2:26pm UTC](https://boards.straightdope.com/t/centering-website/440434/5 "2008-03-07T14:26:11Z")

</div>

And if you’re not using tables or css, just drop a center tag in the code, right after the body tag. Like so:

\<body\>  
**\<center\>**

That’s inelegant (and maybe even non-compliant), but it works and it’s the simplest approach.

---

<div class="post-metadata">

**Author:** ![SharkB8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@SharkB8](https://boards.straightdope.com/u/SharkB8)\
**Post date:** [March 7, 2008, 2:45pm UTC](https://boards.straightdope.com/t/centering-website/440434/6 "2008-03-07T14:45:05Z")

</div>

Awesome guys, thank you so much. I’ll try all of these approaches!

I suck real bad so I used a template and then altered things to my liking…it’s a learning experience.

---

<div class="post-metadata">

**Author:** ![Ponder\_Stibbons](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponder_stibbons/32/343_2.png) [@Ponder\_Stibbons](https://boards.straightdope.com/u/Ponder_Stibbons)\
**Post date:** [March 7, 2008, 2:47pm UTC](https://boards.straightdope.com/t/centering-website/440434/7 "2008-03-07T14:47:11Z")

</div>

Whether you’re just starting out or need a good reference to how all this is _supposed_ to work, try [Html Help](http://www.htmlhelp.com/). I found this site invaluable when I first started messing with making my own web stuff, and I continue to use it as a refence.

It’s best feature is its [list of ALL html tags](http://www.htmlhelp.com/reference/html40/alist.html). All the tags and how they work.

Unfortunately, not all your web page behavior comes from the html tags. The behavior and appearance of those tags can be extended and modified by styles, so for that you’ll need to study [Cascading Style Sheets](http://www.htmlhelp.com/reference/css/). They’re very powerful, but tricky. Even after years of doing this I don’t know all the ins and outs of style sheets.

Anyway, hope that helps.

---

<div class="post-metadata">

**Author:** ![RealityChuck](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/realitychuck/32/195_2.png) [@RealityChuck](https://boards.straightdope.com/u/RealityChuck)\
**Post date:** [March 7, 2008, 3:36pm UTC](https://boards.straightdope.com/t/centering-website/440434/8 "2008-03-07T15:36:19Z")

</div>

Just because you can do this doesn’t mean you should do it.

Centering all the text in the body of the website is a textbook example of ugly web design. Leave centering for headings or graphics. Large blocks of centered text just plain looks bad.

---

<div class="post-metadata">

**Author:** ![FatBaldGuy](https://avatars.discourse-cdn.com/v4/letter/f/ecd19e/32.png) [@FatBaldGuy](https://boards.straightdope.com/u/FatBaldGuy)\
**Post date:** [March 7, 2008, 4:17pm UTC](https://boards.straightdope.com/t/centering-website/440434/9 "2008-03-07T16:17:45Z")

</div>

Are you talking about centering the text in your web page, or centering the browser window in the monitor? If the former, then see the suggestions above. If you’re talking about the latter, then you as a developer have absolutely no control over it.

---

<div class="post-metadata">

**Author:** ![laramary](https://avatars.discourse-cdn.com/v4/letter/l/0ea827/32.png) [@laramary](https://boards.straightdope.com/u/laramary)\
**Post date:** [March 7, 2008, 4:17pm UTC](https://boards.straightdope.com/t/centering-website/440434/10 "2008-03-07T16:17:51Z")

</div>

[QUOTE=RealityChuck]  
Just because you can do this doesn’t mean you should do it.

Centering all the text in the body of the website is a textbook example of ugly web design. Leave centering for headings or graphics. Large blocks of centered text just plain looks bad.  
[/QUOTE]

From my read of the OP, he’s not trying to center the copy, just the area that the copy goes into.

[QUOTE=OP]  
Kinda like now, this message board is centered on my screen. And would be centered on any screen viewing it, there isn’t a lot of extra space on one side of the screen or anything.  
[/QUOTE]

My advice would be to make a table, set the table size for a percent (width =95%) and center the table that you put the content into.

Use the Code and Design view in Dreamweaver (it helped me), open up a fresh page and set up a table. Play with it in the design until you like what you see.

---

<div class="post-metadata">

**Author:** ![Duckster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/duckster/32/1244_2.png) [@Duckster](https://boards.straightdope.com/u/Duckster)\
**Post date:** [March 7, 2008, 4:55pm UTC](https://boards.straightdope.com/t/centering-website/440434/11 "2008-03-07T16:55:26Z")

</div>

You don’t need to use a layout table. You can do it all in CSS.

CSS Guru Dan Cederholm has the classic CSS centering info [on his web site](http://www.simplebits.com/notebook/2004/09/08/centering.html).

Short. Sharp. Shiny. And it works in IE, too.

---

<div class="post-metadata">

**Author:** ![mhendo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mhendo/32/3159_2.png) [@mhendo](https://boards.straightdope.com/u/mhendo)\
**Post date:** [March 7, 2008, 5:06pm UTC](https://boards.straightdope.com/t/centering-website/440434/12 "2008-03-07T17:06:14Z")

</div>

[QUOTE=Duckster]  
You don’t need to use a layout table. You can do it all in CSS.

CSS Guru Dan Cederholm has the classic CSS centering info [on his web site](http://www.simplebits.com/notebook/2004/09/08/centering.html).

Short. Sharp. Shiny. And it works in IE, too.  
[/QUOTE]  
I heartily second this recommendation.

Actually, i’d even ditch the text-align:center command in the body, because people should have ditched IE5 by now anyway.

Just make a fixed-width container div, and give it a value of:

margin: 0 auto

and your content will all be centered.

---

<div class="post-metadata">

**Author:** ![kushiel](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kushiel](https://boards.straightdope.com/u/kushiel)\
**Post date:** [March 7, 2008, 8:10pm UTC](https://boards.straightdope.com/t/centering-website/440434/13 "2008-03-07T20:10:03Z")

</div>

[QUOTE=FatBaldGuy]  
Are you talking about centering the text in your web page, or centering the browser window in the monitor? If the former, then see the suggestions above. If you’re talking about the latter, then you as a developer have absolutely no control over it.  
[/QUOTE]

Um? You do have control over the second one. Seeing the margin:auto container method.

---

<div class="post-metadata">

**Author:** ![kushiel](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kushiel](https://boards.straightdope.com/u/kushiel)\
**Post date:** [March 7, 2008, 8:11pm UTC](https://boards.straightdope.com/t/centering-website/440434/14 "2008-03-07T20:11:40Z")

</div>

[QUOTE=mhendo]  
I heartily second this recommendation.

Actually, i’d even ditch the text-align:center command in the body, because people should have ditched IE5 by now anyway.

Just make a fixed-width container div, and give it a value of:

margin: 0 auto

and your content will all be centered.  
[/QUOTE]

IE6 is still broken on margin:auto though.

---

<div class="post-metadata">

**Author:** ![Barry\_From\_Eastenders](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@Barry\_From\_Eastenders](https://boards.straightdope.com/u/Barry_From_Eastenders)\
**Post date:** [March 7, 2008, 11:16pm UTC](https://boards.straightdope.com/t/centering-website/440434/15 "2008-03-07T23:16:21Z")

</div>

[QUOTE=laramary]  
My advice would be to make a table…  
[/QUOTE]

Never, ever, use a table for layout. It’s against all modern coding standards to do that.

---

<div class="post-metadata">

**Author:** ![Duckster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/duckster/32/1244_2.png) [@Duckster](https://boards.straightdope.com/u/Duckster)\
**Post date:** [March 7, 2008, 11:18pm UTC](https://boards.straightdope.com/t/centering-website/440434/16 "2008-03-07T23:18:52Z")

</div>

[QUOTE=kushiel]  
IE6 is still broken on margin:auto though.  
[/QUOTE]

IE6 is still broken [del]on margin:auto though[/del].

Just correcting for accuracy.

😃

---

<div class="post-metadata">

**Author:** ![mhendo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mhendo/32/3159_2.png) [@mhendo](https://boards.straightdope.com/u/mhendo)\
**Post date:** [March 7, 2008, 11:57pm UTC](https://boards.straightdope.com/t/centering-website/440434/17 "2008-03-07T23:57:16Z")

</div>

[QUOTE=Barry From Eastenders]  
Never, ever, use a table for layout. It’s against all modern coding standards to do that.  
[/QUOTE]  
You know, the few small websites i’ve created use CSS, and i think it’s definitely preferable.

But, to be honest, i think this finger-wagging about using tables is fucking stupid. Yes, i’m well aware of the variety of reasons–from usability to accessibility to separating content from layout–for using CSS rather than tables, but the fact is that CSS can still be a major pain in the ass for people who aren’t web-design experts.

Even leaving aside browser differences, which can be a real shit to code for, the fact is that, for most people, putting together a decent-looking website is light years easier using tables than using CSS. If you’re relatively new to CSS, especially for the purposes of layout, it can literally take you hours to put together a webpage that would take all of 20 minutes using tables. Things like making columns work nicely together are just so much easier using tables than CSS that i don’t blame people for taking the easy route.

Sure, once you’ve worked out CSS and got your site set up, it’s much easier to make changes, because you can make drastic site-wide alterations simply by modifying a few lines of code in the style sheet, but for most people this isn’t a huge issue anyway.

I always recommend that people learn and do their best to use CSS, but i think it’s silly getting all haughty with people who decide that it’s just too goddamn hard.

---

<div class="post-metadata">

**Author:** ![SharkB8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@SharkB8](https://boards.straightdope.com/u/SharkB8)\
**Post date:** [March 8, 2008, 3:28am UTC](https://boards.straightdope.com/t/centering-website/440434/18 "2008-03-08T03:28:02Z")

</div>

Thanks for all of your help everyone. I’m checking this thread now, kinda late, but I’ll work on all of the above suggestions tomorrow.

I am talking about centering the content of the website, not text. I think on some screens, people may have a bar on the bottom to scroll to the right to see all of my page. I don’t have any important content way over there or anything, it’s just sort of an awkward extension of my page and I’d rather it conform to whatever sort of screen is viewing it.

I’m thinking the table route might be best. That’s more like what I’ve seen. Someone will have their color scheme be, say, red, white and blue, within a table with their banner and sidebar all within a box, with a border, then there will be another color in their scheme, say dark blue in the background behind the box, right?

[Here’s](http://www.vacilando.tv) what I have and [here’s](http://www.bigstockphoto.com/) what I’m going for.

---

<div class="post-metadata">

**Author:** ![kushiel](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kushiel](https://boards.straightdope.com/u/kushiel)\
**Post date:** [March 8, 2008, 3:57am UTC](https://boards.straightdope.com/t/centering-website/440434/19 "2008-03-08T03:57:13Z")

</div>

[QUOTE=mhendo]  
You know, the few small websites i’ve created use CSS, and i think it’s definitely preferable.

But, to be honest, i think this finger-wagging about using tables is fucking stupid. Yes, i’m well aware of the variety of reasons–from usability to accessibility to separating content from layout–for using CSS rather than tables, but the fact is that CSS can still be a major pain in the ass for people who aren’t web-design experts.

Even leaving aside browser differences, which can be a real shit to code for, the fact is that, for most people, putting together a decent-looking website is light years easier using tables than using CSS. If you’re relatively new to CSS, especially for the purposes of layout, it can literally take you hours to put together a webpage that would take all of 20 minutes using tables. Things like making columns work nicely together are just so much easier using tables than CSS that i don’t blame people for taking the easy route.

Sure, once you’ve worked out CSS and got your site set up, it’s much easier to make changes, because you can make drastic site-wide alterations simply by modifying a few lines of code in the style sheet, but for most people this isn’t a huge issue anyway.

I always recommend that people learn and do their best to use CSS, but i think it’s silly getting all haughty with people who decide that it’s just too goddamn hard.  
[/QUOTE]

Which is why, if you are running a business, you should hire someone who is a professional. I don’t care what people do on their hobby sites, but Hertz doesn’t go to the manager’s cousin who works out of his two car garage to make their car repairs, which is why a business that needs to have a website shouldn’t go to the manager’s cousin who uses a copy of Frontpage '97.

This view still hasn’t changed. I work in an office that also has print designers, and clients that need brochures and ads wouldn’t ever think of getting the secretary to make one in Word and print 500 copies on their crappy inkjet printer. Yet people think you can do the equivalent on websites.

This is getting out of GQ territory so I’ll stop here.

---

<div class="post-metadata">

**Author:** ![GuanoLad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/guanolad/32/42_2.png) [@GuanoLad](https://boards.straightdope.com/u/GuanoLad)\
**Post date:** [March 8, 2008, 4:00am UTC](https://boards.straightdope.com/t/centering-website/440434/20 "2008-03-08T04:00:28Z")

</div>

[QUOTE=Barry From Eastenders]  
Never, ever, use a table for layout. It’s against all modern coding standards to do that.  
[/QUOTE]

That’s overstating it a bit. It’s more correct to say it’s discouraged from within the web coding community. There’s nothing actually detrimental with using tables for formatting a page, though it can restrict a little.

The problem is, CSS doesn’t provide a formatting alternative that is as good and as logical as tables. Something as simple as a fixed height, variable width, three column layout is a piece of cake using tables, but a complete nightmare to figure out with CSS. Almost your only option is to locate a site where someone else has done the hard work and copy from them. And even then it probably won’t work quite so prettily in a couple of stubborn browsers and you’ll have to hack it around.

[Next page](https://boards.straightdope.com/t/centering-website/440434.md?page=2)
