Table wont Centre in FF 3?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziycon
    Contributor
    • Sep 2008
    • 384

    #1

    Table wont Centre in FF 3?

    I have the below code, now the text outside of the table will centre fine in IE and FF but the table will not centre at all in FF but is fine in IE??

    Code:
    <div id="search_body_wrapper">
        <div id="search_body_results">
            <b>3</b> result(s) found for <b>test</b>.<br /><br />
            <table border="0" cellspacing="2" cellpadding="2">
                <tr style="background-color: #CCCCCC;"><td style="font-weight: bold;">Case Number</td><td style="font-weight: bold;">Summary</td></tr>
                <tr style="background-color: #DEDEDE;"><td>1000001</td><td>Test Case 1</td></tr>
                <tr style="background-color: #DEDEDE;"><td>1000002</td><td>Test Case 2</td></tr>
                <tr style="background-color: #DEDEDE;"><td>1000013</td><td>Test Case, Entered via web form</td></tr>
            </table>
        </div>
    </div>
    Code:
    #search_body_wrapper {
        float: left;
        width: 800px;
        margin: 5px 5px 0 5px;
        padding: 0 0 5px 0;
        background-color: #FFFFFF;
        text-align: left;
        clear: left;
        display: inline;
    }
    #search_body_results {
        float: left;
        width: 100%;
        margin: 5px 0 0 0;
        text-align: center;
        clear: left;
        display: inline;
    }
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Well, you're floating it left, so it's supposed to be on the left side. Why would it be different?

    I don't have IE available so I haven't a clue why IE is doing it wrong and centering it but I'd bet all the modern browsers don't center it either.

    Anyway, to center the table, put this in your CSS:
    Code:
    table{
    margin:0 auto
    }
    and never, ever look at IE as a reference for how things should work.

    Comment

    • Stomme poes
      New Member
      • Aug 2007
      • 14

      #3
      IE is possibly doing it wrong because there's no doctype, or an incomplete doctype, or some text or something before the doctype. IE in Quirks Mode will let text-align center blocks like tables when it shouldn't.

      If the margin: 0 auto thing doesn't work at first, make sure that

      the thing you want to center has a width
      and
      that width isn't 100% (you can't center something that's 100% wide)

      Comment

      Working...