body tag for width and centering

Discussion in 'HTML' started by Sally West, Jul 24, 2004.

  1. Sally West

    Sally West Guest

    Hi

    Is there a tag for the body element to fix the width of the page?

    And how do you center a page if it is narrower than the screen width?

    It seems to default to the left.

    Thanks
     
    Sally West, Jul 24, 2004
    #1
    1. Advertising

  2. Sally West

    Webcastmaker Guest

    In article <>,
    says...
    > Is there a tag for the body element to fix the width of the page?
    > And how do you center a page if it is narrower than the screen width?
    > It seems to default to the left.


    The first thing you need to do is go to www.w3schools.com and run
    through the HTML and CSS tutorials. It will take you an hour or so,
    and it will be more valuable than any answer you get for your
    questions.

    Oh yea, one way is use CSS to make the body center everything and put
    a div in the body that uses CSS to set the width of the div.

    --
    WebcastMaker
    The easiest and most affordable way to create
    Web casts, or put presentations on the Web.
    www.webentations.com
     
    Webcastmaker, Jul 24, 2004
    #2
    1. Advertising

  3. Sally West

    rf Guest

    Sally West wrote:

    > Hi


    G'day.

    > Is there a tag


    You mean attribute.

    > for the body element to fix the width of the page?


    No. The body element *is* the page.

    You would have to enclose your content in, say, a div element and set the
    width of that, but you would not use the width attribute, you would use some
    CSS.

    <head>
    <style type="text/css">
    ..content {width: 600px;}
    </style>
    </head>
    <body>
    <div class="content">
    your content goes here.
    </div>

    > And how do you center a page if it is narrower than the screen width?


    by specifying margin: auto

    ..content {width: 600px; margin: auto;}

    However this does not work in IE6 in quirks mode and prior versions of IE,
    5.5 or below, so you need to also specify

    body {text-align: center}

    to utilize a bug in IE where it this not only aligns the text but also the
    block level elements like divs. But then your text is centred so you also
    need to cancel thus in the div by specifying text-align: left;

    body {text-align: center}
    ..content {width: 600px; margin: auto; text-align: left;}

    However, why do you want to fix the size of you page anyway? It's best to
    let the page flow to the size of your users canvas:

    http://allmyfaqs.com/faq.pl?AnySizeDesign


    --
    Cheers
    Richard.
     
    rf, Jul 24, 2004
    #3
  4. Sally West

    Spartanicus Guest

    "rf" <rf@.invalid> wrote:

    >> Is there a tag

    >
    >You mean attribute.
    >
    >> for the body element to fix the width of the page?

    >
    >No. The body element *is* the page.


    Incorrect, the body element is a block level element that can be given a
    width and centered.

    --
    Spartanicus
     
    Spartanicus, Jul 24, 2004
    #4
  5. Sally West

    rf Guest

    Spartanicus wrote
    > "rf" <rf@.invalid> wrote:


    > >No. The body element *is* the page.

    >
    > Incorrect, the body element is a block level element that can be given a
    > width and centered.


    I stand corrected.

    I was experimenting with IE in quirks mode, maybe that is what confused me.

    In any case, even though the body element can be sized and centred this does
    not work with IE in quirks mode (or IE<6 I presume) so my solution still
    stands, I think :)

    --
    Cheers
    Richard.
     
    rf, Jul 24, 2004
    #5
  6. Sally West

    C A Upsdell Guest

    "Spartanicus" <> wrote in message
    news:...
    > "rf" <rf@.invalid> wrote:
    >
    > >> Is there a tag

    > >
    > >You mean attribute.
    > >
    > >> for the body element to fix the width of the page?

    > >
    > >No. The body element *is* the page.

    >
    > Incorrect, the body element is a block level element that can be given a
    > width and centered.


    But not with older versions of IE. So putting a DIV inside the BODY is the
    best way to do it if you want it to work with older browsers.
     
    C A Upsdell, Jul 24, 2004
    #6
    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. AndrewF
    Replies:
    1
    Views:
    847
    Bruce Barker
    Oct 10, 2005
  2. shruds
    Replies:
    1
    Views:
    961
    John C. Bollinger
    Jan 27, 2006
  3. Damien Sawyer

    Centering body using CSS

    Damien Sawyer, Aug 16, 2004, in forum: HTML
    Replies:
    3
    Views:
    12,673
    Damien Sawyer
    Aug 16, 2004
  4. London Boy
    Replies:
    2
    Views:
    359
    Keith Bowes
    Jan 12, 2004
  5. Replies:
    5
    Views:
    239
    A. Sinan Unur
    Sep 8, 2005
Loading...

Share This Page