placing webpages in the centre of the window

Sharky Forums


Results 1 to 5 of 5

Thread: placing webpages in the centre of the window

  1. #1
    Goldfish qwe's Avatar
    Join Date
    Sep 2002
    Location
    London
    Posts
    69

    placing webpages in the centre of the window

    I have noticed an increasing number of websites that have their position centred within the browser window. I have looked at their code but am finding it difficult to seperate the code that does this from the rest. Can anyone make this clearer for me?

    thanks
    Possesions never meant anything to me,
    I'm not crazy.
    Well that's not true I have a bed,
    and a guitar and a dog named dog.

  2. #2
    Not Pirate... Arrrchiver Mr Cherry's Avatar
    Join Date
    Dec 2000
    Location
    By the Beach in California
    Posts
    8,090
    Make a table for the entire website to sit in, and center that table. That's how I do it.
    ---> : : : computer specs : : : <---
    :::heatware:::


    Currently playing: World of Warcraft [Lightbringer Realm]

    ''Ah ha ha ha ha ha! Sixty seconds till midnight…sixty seconds to nowhere, baby! You have all become victims of the Evil Midnight Bomber What Bombs… Hey! Pay Attention!"


    update: 2/28/08

  3. #3
    Mako Shark slavik's Avatar
    Join Date
    May 2001
    Location
    Brooklyn
    Posts
    3,308
    <html><body><center>

    lots of code here

    </center></body></html>
    Activation? What activation?
    Quote Originally Posted by Geekkit (from ubuntu forums regarding 'goto' statement)
    Yep it sure does. So does crack cocaine. Existence is not a valid endorsement for being acceptable.
    Quote Originally Posted by Linus Torvalds
    Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it

  4. #4
    Goldfish qwe's Avatar
    Join Date
    Sep 2002
    Location
    London
    Posts
    69
    thanks for the replies. It's been very useful.
    Possesions never meant anything to me,
    I'm not crazy.
    Well that's not true I have a bed,
    and a guitar and a dog named dog.

  5. #5
    Really Cold Shark eshbach's Avatar
    Join Date
    May 2003
    Location
    San Luis Obispo, CA
    Posts
    5,740
    both of the answers above are incorrect... or at least, bad solutions.

    This is how you'll want to do it:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title>Centered Web Page</title>
            <style type="text/css">
                #centeredContent
                {
                    margin-left: auto;
                    margin-right: auto;
                    width: (something);
                }
            </style>
        </head>
        <body>
            <div id="centeredContent">
                This content will appear in the center.
            </div>
        </body>
    </html>

    Also, always remember that this document is your best friend: http://www.w3.org/TR/CSS21/

Posting Permissions

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