View Full Version : how do people centre websites??

08-09-2007, 06:36 AM
hi i have been noticing a lot these days websites which are centered. this is good as people are getting widescreen computers and stuff that it doesn't stretch the image accross the screen.
for example if i make a website on my computer that has a 17'' screen and then view it on a 20 inch widescreen or for the matter any widescreen does the page automatically center itself or is there some special code i need to include in my html.

thanks a lot in advance

08-09-2007, 07:24 AM
the stylesheet command for centering block level content is

margin:0 auto;

You also need to supply a width.

So if you wrap all of your content in a div and want it 700 pixels wide and centred you would use:

<div id="wrapper"></div>

around the content and place the following in the stylesheet

#wrapper {width:700px;margin:0 auto;}

(and if it doesn't appear to work in IE then it means that the browser is not recognising your doctype)

08-09-2007, 07:33 AM
thanks a heap for that ;)

now i can make my webpages look better...