How to make a "container" div a certain size as well as centre it.

Discussion in 'HTML' started by xxfiredragonxx, Dec 19, 2005.

  1. If you are all wondering how to create a centred div with a certain
    size, as well as a margin, the way I do it is like this:

    #container {
    width: 775px;
    background: #fff;
    margin: 1em auto;
    text-align: left;
    }

    the WIDTH is for the size of the actual div
    background is so then it'll come up at front of the background.
    MARGIN is how you center it. AUTO automatically calculates the size of
    the window and centres it in the page. 1em is how much space is
    between the DIV and the page itself. You can set it to 0 if you want.
    TEXT-ALIGN is just there to fix the text if something in the CSS has it
    set to something like CENTER or RIGHT.

    - Mark

    P.S.This is just my own knowlege, it's not off of any website.
    xxfiredragonxx, Dec 19, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy:P
    Replies:
    8
    Views:
    498
    Andy Peat
    Jan 15, 2004
  2. chris

    DIV relative to centre ?

    chris, Aug 25, 2004, in forum: HTML
    Replies:
    6
    Views:
    9,623
    Daniel
    Sep 7, 2004
  3. Ant
    Replies:
    7
    Views:
    454
  4. Vince Morgan

    Centre an image in a <div>

    Vince Morgan, Nov 16, 2006, in forum: HTML
    Replies:
    10
    Views:
    887
    Vince Morgan
    Nov 16, 2006
  5. benjamin
    Replies:
    2
    Views:
    114
    benjamin
    Nov 16, 2005
Loading...

Share This Page