Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Can't center webpage in IE browser window

    Hello. Using the most recent versions of web browsers...

    Firefox: Ver. 22.0
    Google Chrome: Ver. 27.0
    Opera: Ver. 12.15
    Safari: Ver. 5.17
    IE: Ver. 10.0

    Using CSS, the first page of my website (not online yet), index.html, DOES center correctly within the browser's window. But when using IE versions 8.0 and 9.0 (and I suspect older versions of IE and perhaps some older versions
    of the browsers above too), the webpage is not centered.

    Here's a snippet of the CSS code I used which I found on the web...
    <code>

    <style type="text/css">
    <!-- /* add HTML comment to protect older browsers */

    #container {
    width: 950px;
    margin: 0px auto;
    text-align: center; /* added as margin code not recognized by IE5.0 */
    background-color: #ffffff;
    }
    -->
    </style>

    <body>
    <div id="container">

    blah, blah, blah (I used tables for the webpage)

    </div>
    </body>
    </html>

    </code>

    I even removed the comment above within CSS section but that did not change anything. And also note that a previous index.html page I was using (pure HTML) did center the page within all browsers both old and new, as I used align="center" code in tables, iframes, etc. But I want to use CSS now as it is the way to go these days.

    QUESTION: What coding can I add or change in the CSS above to fix this problem with older browsers?

    Thanks for any help. I'm thinking there is a simple solution to this problem.
    Henry

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    First of all let me say that IE 6 only has 6.03% of marketshare (the last XP boxes still online) so I really don't think you need to worry about IE5 by commenting out your inline styles and adding text-align:center. Just my two cents, feel free to do as you please with your site.

    Source: http://www.netmarketshare.com/browse...=2&qpcustomd=0

    What DOCTYPE are you using?
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New Coder
    Join Date
    Aug 2012
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks for your response. Sorry it took me a bit to get back to you.
    I use the following DOCTYPE...

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    I also include this line too...
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

    Since you asked that question, I just Googled this. One person said including "transitional" is not needed, as that was for older 3.2 HTML coding which is too old to worry about now. Below is what this person suggested...

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    What is your suggestion? And what about that 2nd line I include?

    Thanks.
    Henry

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Yes, I would recommend the "STRICT" HTML 4.01 DOCTYPE or the newer HTML 5 DOCTYPE which is simply <!DOCTYPE html>

    Using the transitional html 4.01 doctype throws the browser into quirks mode.
    See: http://en.wikipedia.org/wiki/Quirks_...document_types

    Let me know if that solves it or not.

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    New Coder
    Join Date
    Aug 2012
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hello Whizard:

    Actually, I also posted my question on one other help website, namely htmlcodetutorial.com.

    After using Google and searching and trying different things myself, I then decide to get some help from a website or two and hope for an answer. On the site above, I actually got a very extensive answer which I implemented and solved my problem.

    In regard to the DOCTYPE, thanks for bringing that up! I have updated all my files to the strict HTML 4 DOCTYPE as you advised.

    So, thanks very much for the information and your time. It is appreciated.

    Henry


  •  

    Posting Permissions

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