How can I center my site

Posted on 2011-04-23
Last Modified: 2012-05-11
Hello, I have a pretty basic knowledge of CSS and I'm trying to center this website:

I tried aplying text-align to the primary div but everything inside got centered.

Thanks in advance.
Question by:IvanGarcete
    LVL 13

    Assisted Solution

    If you want to center a div, you have to set margins.

    For a div that is 800px wide, it would look like this.
    #center {
      Width: 800px;
      Height: 100%;
      Margin: 0pt auto;

    Open in new window

    Obviously you can make it whatever height or width you want.
    LVL 13

    Expert Comment

    Sorry about the capital letters in the syntax. They should be lower case. Typing on an iPad.
    LVL 82

    Accepted Solution

    I would use this.  984px looks like your widest element.
      width: 984px;
      margin-left: auto;
      margin-right: auto;

    Open in new window


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
    In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now