www.webdeveloper.com
Results 1 to 5 of 5

Thread: Centering the whole page

  1. #1
    Join Date
    Jan 2007
    Location
    Shropshire, UK
    Posts
    77

    Centering the whole page

    Hi,

    Apologies I know the answer must be on here but my searches dont find the answer for me.

    Im trying to build a page which is center aligned. I have used margin:0 auto on the main sections but whilst FF works, IE has it stuck to the defaul left.

    My page is here:
    http://www.whizzliz.co.uk/CSSlayoutd...lutestmod.html

    Can anyone please advise what i have done wrong.

    Many thanks
    Liz

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>Basic centering</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <style type="text/css">
    #centered {text-align:center;}
    #container {margin:0 auto; width:80&#37;; text-align:left;}
     
    </style>
    
    </head>
    <body>
    <!-- Center contents -->
    <div id="centered"><div id="container">
       <div id="contents" style="border:1px solid red;">
       	<p>contents</p>
       </div>
    </div></div>
    </body>
    </html>
    </body>
    </html>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Jan 2007
    Location
    Shropshire, UK
    Posts
    77
    Many thanks!

    i have also just remember that I hadnt used a doctype! Adding that in to the original code now makes it work. I hate IE!!

    Liz

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The DTD on it's own won't center the contents in older versions of IE.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,211
    Still didn't see the DocType for "lulutestmod.html". :P

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles