Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation how do people centre websites??

    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

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    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)
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thanks a heap for that

    now i can make my webpages look better...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •