New OOTS products from CafePress
New OOTS t-shirts, ornaments, mugs, bags, and more
Results 1 to 9 of 9
  1. - Top - End - #1
    Barbarian in the Playground
     
    Kumori's Avatar

    Join Date
    Mar 2005
    Location
    Edmonton, AB
    Gender
    Male

    Default Centering Multiple Table Cells

    I'm in the middle of writing up a homebrew class and in making one of the tables I've run into a problem. I want to center the text within each of the cells. Is there a simple way to do this, or would I need to use the [center][/center] tags inside each individual cell?
    That's over 220 cells.... ugh, I can feel the headache already!


    Same question, different way of asking:
    Is there an easy way to make the following table look like the centered table below it?

    {table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    1|2|3|4|5
    1|2|3|4|5
    1|2|3|4|5[/table]

    {table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    1
    |
    2
    |
    3
    |
    4
    |
    5
    1
    |
    2
    |
    3
    |
    4
    |
    5
    1
    |
    2
    |
    3
    |
    4
    |
    5
    [/table]

    Hmm... Even with individual center tags, I can't get the example table here to work. It's keeps glitching and erasing some of the tags on me whenever I click the preview button... So weird.
    Last edited by Kumori; 2012-04-01 at 02:17 AM.

  2. - Top - End - #2
    Ettin in the Playground
     
    Shhalahr Windrider's Avatar

    Join Date
    Nov 2005
    Location
    By a Park
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    Quote Originally Posted by Kumori View Post
    Hmm... Even with individual center tags, I can't get the example table here to work. It's keeps glitching and erasing some of the tags on me whenever I click the preview button... So weird.
    Yeah, there is a bug in the parser. Table screws up certain tags at the beginning and end of each row unless you add a gratuitous pipe before hitting the carriage return. In other words, pretend the last cell of each row actually has an extra cell with no content after it. Like so:

    {table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    [CENTER]1[/CENTER]|[CENTER]2[/CENTER]|[CENTER]3[/CENTER]|[CENTER]4[/CENTER]|[CENTER]5[/center]|
    [center]1[/CENTER]|[CENTER]2[/CENTER]|[CENTER]3[/CENTER]|[CENTER]4[/CENTER]|[CENTER]5[/center]|
    [center]1[/CENTER]|[CENTER]2[/CENTER]|[CENTER]3[/CENTER]|[CENTER]4[/CENTER]|[CENTER]5[/CENTER][/table]

    Gives you:
    {table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    1
    |
    2
    |
    3
    |
    4
    |
    5
    |
    1
    |
    2
    |
    3
    |
    4
    |
    5
    |
    1
    |
    2
    |
    3
    |
    4
    |
    5
    [/table]

    As to your primary question:
    If you don’t mind the table itself being centered, you can place “center” tags around the whole table, and each cell will inherit the centering:

    [center]{table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    1|2|3|4|5
    1|2|3|4|5
    1|2|3|4|5[/table][/center]

    Gives you:

    {table=head]Example table|Yippee!|Woot|Huh?|Oh, really...?
    1|2|3|4|5
    1|2|3|4|5
    1|2|3|4|5[/table]
    Last edited by Shhalahr Windrider; 2012-04-01 at 09:37 AM.
    The Future just ain’t what it used to be.

  3. - Top - End - #3
    Bugbear in the Playground
    Join Date
    Feb 2011

    Default Re: Centering Multiple Table Cells

    It doesn't inherit centering on my Firefox 11.

  4. - Top - End - #4
    Ettin in the Playground
     
    Shhalahr Windrider's Avatar

    Join Date
    Nov 2005
    Location
    By a Park
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    Quote Originally Posted by Snowbody View Post
    It doesn't inherit centering on my Firefox 11.
    Okay. Well, now I am wondering if it is Firefox or Opera that is misbehaving. I’ll have to go look that up.
    The Future just ain’t what it used to be.

  5. - Top - End - #5
    Titan in the Playground
     
    Grey_Wolf_c's Avatar

    Join Date
    Aug 2007

    Default Re: Centering Multiple Table Cells

    Quote Originally Posted by Shhalahr Windrider View Post
    Okay. Well, now I am wondering if it is Firefox or Opera that is misbehaving. I’ll have to go look that up.
    For what is worth, it is also not being inherited in Safari.

    GW
    Interested in MitD? Join us in MitD's thread.
    There is a world of imagination
    Deep in the corners of your mind
    Where reality is an intruder
    And myth and legend thrive
    Quote Originally Posted by The Giant View Post
    But really, the important lesson here is this: Rather than making assumptions that don't fit with the text and then complaining about the text being wrong, why not just choose different assumptions that DO fit with the text?
    Ceterum autem censeo Hilgya malefica est

  6. - Top - End - #6
    Ettin in the Playground
     
    Shhalahr Windrider's Avatar

    Join Date
    Nov 2005
    Location
    By a Park
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    Okay, well apparently the center tag uses the deprecated DIV align attribute rather than CSS. Of course, using a simple CSS text-align wouldn’t center the table anyway, though it does appear to center the text within it.
    The Future just ain’t what it used to be.

  7. - Top - End - #7
    Barbarian in the Playground
     
    Kumori's Avatar

    Join Date
    Mar 2005
    Location
    Edmonton, AB
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    So in the end I have to center each cell individually. Tedious, but that's just the way it is. In any case, thanks for the help.

  8. - Top - End - #8
    Ettin in the Playground
     
    Shhalahr Windrider's Avatar

    Join Date
    Nov 2005
    Location
    By a Park
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    Quote Originally Posted by Kumori View Post
    So in the end I have to center each cell individually. Tedious, but that's just the way it is. In any case, thanks for the help.
    You could cut down on the tedium by composing the table with a text editor and then using the Find and Replace function to replace every “|” with “[center]|[/center]”. If your text editor works properly, you may also be able to make it work with the end of row cells—type it out once and the copy and paste it into the find/replace fields.

    Or you could just copy a “[center]|[/center]” to the clpboard and at the end of each cell, instead of typing the whole thing out, press Ctrl-V, or ⌘-V if you are a Mac user. That makes it easier.
    The Future just ain’t what it used to be.

  9. - Top - End - #9
    Miniature Giant Space Hamster in the Playground Administrator
     
    Rawhide's Avatar

    Join Date
    Sep 2005
    Location
    Australia
    Gender
    Male

    Default Re: Centering Multiple Table Cells

    Or just pre-set up the table, then type your data in between the [center][/center].

    "My Hobby: Replacing your soap with gravy" by rtg0922, Doll and Clint "Rawhide" Eastwood by Sneak

Posting Permissions

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