1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

CSS Centering

Discussion in 'Web Development' started by 355th_Sniped, Jul 1, 2008.

  1. 355th_Sniped

    355th_Sniped New Member

    Hi guys, i am currently working on a new project where by i want my content to be centered on the page.

    I have a header image which is 750px, but i want to be able to center it on my page. I can do this with px but if i use a different screen all my content looks off to the left. I therefore have decided to use the % attribute for my container but cannot think of a way of centering my header. I thought perhaps trial and error to find the center just with % but there must be an easier way right?

    I do not wish to use simple HTML but rather use css to do this, as i like to use XHTML, and keep it strict.

    Cheers for any help you can provide.
     
  2. vareside

    vareside New Member

    Well, I know that it works with HTML in following way. Add directly below <body> the following: <div align="center"> and add directly above </body> this part: </div>

    For the CSS version I have a few ideas. The first possibility is that you add to the part where the body tag is specified this: float: center;
    Maybe that works. Another way is to set margin. For example add again to the part where the body is being specified this: margin: 60px 10px 30px;
    But it won't keep it in the centre, it will only keep it away from the top of the page, the left side of the page and the bottom of the page.