Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Centering a table using only CSS

  • 17-05-2006 03:57PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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