Center Tables with CSS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bastian

    Center Tables with CSS

    Hi,

    I have a very crazy problem with CSS. I have tried to center my tables
    with
    TABLE {margin-left:auto; margin-right:auto}
    how it is described in many other postings.
    Mozilla and Konqueror are accepting this way of centering the table
    but not IE.
    I also tried
    TABLE {margin-left: 0 auto}
    which I have seen recently, too. But nothing works.

    Had anyone the same problem and can help me. If not, I have to center
    the tables with the "align" attribute. But if it's possible I want to
    avoid that.

    Bye

    Bastian
  • Martin Honnen

    #2
    Re: Center Tables with CSS



    Bastian wrote:
    [color=blue]
    > I have a very crazy problem with CSS. I have tried to center my tables
    > with
    > TABLE {margin-left:auto; margin-right:auto}
    > how it is described in many other postings.
    > Mozilla and Konqueror are accepting this way of centering the table
    > but not IE.[/color]

    I think IE6/Win should do the right thing with that CSS if you make sure
    your document is rendered in CSS standards-compliant mode

    --

    Martin Honnen


    Comment

    • Els

      #3
      Re: Center Tables with CSS

      Bastian wrote:
      [color=blue]
      > Hi,
      >
      > I have a very crazy problem with CSS. I have tried to center my tables
      > with
      > TABLE {margin-left:auto; margin-right:auto}
      > how it is described in many other postings.
      > Mozilla and Konqueror are accepting this way of centering the table
      > but not IE.
      > I also tried
      > TABLE {margin-left: 0 auto}
      > which I have seen recently, too. But nothing works.
      >
      > Had anyone the same problem and can help me. If not, I have to center
      > the tables with the "align" attribute. But if it's possible I want to
      > avoid that.[/color]

      For IE5 (and 4) you will need the center:align; property in
      the style of the parent element.
      http://locusmeus.com/html-css/centeringpage.html is about
      centering a page, but the same principle goes for tables,
      I'd think.



      --
      Els
      Blog and other pages, mostly outdated.

      Sonhos vem. Sonhos vão. O resto é imperfeito.
      - Renato Russo -

      Comment

      • David Dorward

        #4
        Re: Center Tables with CSS

        Bastian wrote:
        [color=blue]
        > I have a very crazy problem with CSS.[/color]

        comp.infosystem s.www.authoring.stylesheets is a couple of doors along, this
        is the html authoring newsgroup.
        [color=blue]
        > I have tried to center my tables
        > with
        > TABLE {margin-left:auto; margin-right:auto}
        > how it is described in many other postings.
        > Mozilla and Konqueror are accepting this way of centering the table[/color]

        Yup, they are good browsers.

        [color=blue]
        > but not IE.[/color]

        You are probably using an obsolete version of IE, or are failing to trigger
        standards mode.

        http://dorward.me.uk/www/centre/#ie explains the work arounds.
        [color=blue]
        > I also tried
        > TABLE {margin-left: 0 auto}[/color]

        This means the same as:

        margin-top: 0;
        margin-bottom: 0;
        margin-left: auto;
        margin-right: auto;

        --
        David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
        Home is where the ~/.bashrc is

        Comment

        • Spartanicus

          #5
          Re: Center Tables with CSS

          David Dorward <dorward@yahoo. com> wrote:
          [color=blue][color=green]
          >> I also tried
          >> TABLE {margin-left: 0 auto}[/color]
          >
          >This means the same as:
          >
          >margin-top: 0;
          >margin-bottom: 0;
          >margin-left: auto;
          >margin-right: auto;[/color]

          Margin-left only takes one value, correct usage: "margin:0 auto".

          --
          Spartanicus

          Comment

          • Els

            #6
            Re: Center Tables with CSS

            Spartanicus wrote:
            [color=blue]
            > David Dorward <dorward@yahoo. com> wrote:
            >[color=green][color=darkred]
            >>>I also tried
            >>>TABLE {margin-left: 0 auto}[/color]
            >>
            >>This means the same as:
            >>
            >>margin-top: 0;
            >>margin-bottom: 0;
            >>margin-left: auto;
            >>margin-right: auto;[/color]
            >
            > Margin-left only takes one value, correct usage: "margin:0 auto".[/color]

            I just looked at this sentence of yours, and the code above,
            and again, and once more.. and then I saw the difference.

            Funny how you see what you're expecting to see, while it's
            not really there ;-)

            --
            Els
            Blog and other pages, mostly outdated.

            Sonhos vem. Sonhos vão. O resto é imperfeito.
            - Renato Russo -

            Comment

            • David Dorward

              #7
              Re: Center Tables with CSS

              Spartanicus wrote:
              [color=blue]
              > Margin-left only takes one value, correct usage: "margin:0 auto".[/color]

              Whoops - misread the previous post.

              --
              David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
              Home is where the ~/.bashrc is

              Comment

              Working...