Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Centering a table using only CSS

Options
  • 17-05-2006 3:57pm
    #1
    Registered Users Posts: 1,709 ✭✭✭


    Hey, I'm trying to centre a fixed width table using only CSS. I don't have any access to modify the HTML itself.

    Right now, all I've got to work with is a TABLE insidie a FORM inside the BODY of the document. I was able to centre using:
    form {
    	width: 750px;
    	margin-left: auto;
    	margin-right: auto;
    }
    
    but that only displayed correctly in Opera and Firefox, not IE.

    Is there any way to centre any of the three containers at a fixed width using CSS alone?

    If it's relevant, none of the mentioned objects have a class or id :(


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    add

    body {
    text-align: center; /* for IE */
    }


  • Registered Users Posts: 1,709 ✭✭✭Balfa


    Thankyou Ph3n0m. Poifect!


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    on a side note, in IE, you may notice stuff aligning to the center - just specify text-align:left for whatever else you have on the page -- as sometimes in IE, the text-align:center cascades down and aligns everything in the middle that is not pegged down


  • Registered Users Posts: 1,709 ✭✭✭Balfa


    I was somewhat confused as to why your solution worked, but eventually found http://dorward.me.uk/www/centre/ which explains it. :) Thanks again! :)


Advertisement