SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Jan 2001
    Location
    Ottawa ON
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please Provide a Simple Answer: What is the CSS equivalent of <table align="center">

    Please Provide a Simple Answer: I'm wondering what the CSS equivalent of <table align="center"> is. I searched Google for this and came upon this discussion which didn't seem to arrive at a clear answer:
    http://lists.w3.org/Archives/Public/...7Oct/0064.html

    Four years later I'm sure that there is somethign very simple, but I don't knwo what it is.

    <table align="center">
    <table style="?????:center">

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Addict
    Join Date
    Jan 2001
    Location
    Ottawa ON
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Text-align doesn't seem to work - it centers text inside of the table and that's not what I want.

    <table align="center"> makes the table itself centerd and doesn't affect the positioning of the text inside of that table.

    <table style="text-align:center"> doesn't center the table (which I tried it the table was in its default position - left aligned) and the text inside of the table was centered.

    What I want to do - center the table, but not the text. This is what <table align="center"> does. What is the CSS equivalent?

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah right, margin-left: auto; margin-right: auto; is what you need.

  5. #5
    SitePoint Addict
    Join Date
    Jan 2001
    Location
    Ottawa ON
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Anarchos
    Ah right, margin-left: auto; margin-right: auto; is what you need.
    That seems so very arcane and bizarre - like a CSS kludge. Surely within all of the table formatting specs in CSS2 there is something that explicitly defines 'center'.

    I'll start using that, but I consider center something basic and I think that's a bizarre design decision on the part of the W3C. There are a lot of elements in CSS that you can explicitly center, text for one. why should tables be the exception?
    Last edited by prowsej; Jun 26, 2001 at 10:03.

  6. #6
    SitePoint Enthusiast ben_washington's Avatar
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what your trying to do is:

    <style type="text/css">
    <!--

    table.class{align:center;}

    -->
    </style>

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Technically, you should be putting any content that needs centering inside a DIV tag and centering the DIV itself.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Madison, Wisconsin
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here are a couple of links that deal with centering block level elements using CSS.

    http://bluerobot.com/web/css/center1.html
    http://bluerobot.com/web/css/center2.html

    bluerobot.com also has some very nice layouts that you can look at and view the stylesheets.


Bookmarks

Posting Permissions

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