Center Table but not Caption!

Discussion in 'HTML' started by sorry.no.email@post_NG.com, May 3, 2006.

  1. Hi,

    I am trying to center a table using CSS on the following page:

    http://people.aapt.net.au/~adjlstrong/foster/chapter_2.html

    The table is captioned '1848 Census'. CSS is at:

    http://people.aapt.net.au/~adjlstrong/layout.css

    Some of the tables on the site are centered, not all, and I have
    centered this particular table using:

    ..centered-table {
    margin-left: auto;
    margin-right: auto;
    }

    This is fine but the Caption remains firmly at the extreme left,
    presumably obeying the general caption rules (text-align) above it:

    caption {
    padding: 0 0.6em 0.8em;
    font-size: 1.3em;
    font-weight: bold;
    text-align: left;
    color: #000;
    background: transparent;
    }

    Can anybody suggest a work-around for this?

    Thanks for your trouble,

    Andrew.
     
    sorry.no.email@post_NG.com, May 3, 2006
    #1
    1. Advertising

  2. sorry.no.email@post_NG.com

    Martin Jay Guest

    In message <>,
    sorry.no.email@post_NG.com writes

    >Some of the tables on the site are centered, not all, and I have
    >centered this particular table using:
    >
    >.centered-table {
    > margin-left: auto;
    > margin-right: auto;
    >}
    >
    >This is fine but the Caption remains firmly at the extreme left,
    >presumably obeying the general caption rules (text-align) above it:
    >
    >caption {
    > padding: 0 0.6em 0.8em;
    > font-size: 1.3em;
    > font-weight: bold;
    > text-align: left;
    > color: #000;
    > background: transparent;
    >}
    >
    > Can anybody suggest a work-around for this?


    Well, one work-around would be to give the <caption> a class, such as
    this:

    <caption class="caption_centre">
    1848 Census
    </caption>

    And in the CSS:

    ..caption_centre{
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    }

    --
    Martin Jay
    Phone/SMS: +44 7740 191877
    Fax: +44 870 432 5180
     
    Martin Jay, May 3, 2006
    #2
    1. Advertising

  3. On Wed, 3 May 2006 00:55:35 +0100, Martin Jay
    <> wrote:

    >In message <>,
    >sorry.no.email@post_NG.com writes
    >
    >>Some of the tables on the site are centered, not all, and I have
    >>centered this particular table using:
    >>
    >>.centered-table {
    >> margin-left: auto;
    >> margin-right: auto;
    >>}
    >>
    >>This is fine but the Caption remains firmly at the extreme left,
    >>presumably obeying the general caption rules (text-align) above it:
    >>
    >>caption {
    >> padding: 0 0.6em 0.8em;
    >> font-size: 1.3em;
    >> font-weight: bold;
    >> text-align: left;
    >> color: #000;
    >> background: transparent;
    >>}
    >>
    >> Can anybody suggest a work-around for this?

    >
    >Well, one work-around would be to give the <caption> a class, such as
    >this:
    >
    ><caption class="caption_centre">
    > 1848 Census
    ></caption>
    >
    >And in the CSS:
    >
    >.caption_centre{
    > text-align: center;
    > margin-left: auto;
    > margin-right: auto;
    >}

    Hi Martin,

    Thanks for this! I have changed it to

    ..caption_centre{
    text-align: left;
    margin-left: auto;
    margin-right: auto;

    and this has produced the desired effect: centered on page but aligned
    left with respect to the table top.

    Thanks very much!

    Andrew.
     
    sorry.no.email@post_NG.com, May 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luigi Donatello Asero

    Bobby and caption of a table

    Luigi Donatello Asero, Jul 5, 2004, in forum: HTML
    Replies:
    20
    Views:
    917
    Psyonicdreams
    Jul 10, 2004
  2. Fernie
    Replies:
    5
    Views:
    4,259
    Jukka K. Korpela
    Dec 3, 2004
  3. Replies:
    1
    Views:
    559
    bruce barker
    Mar 7, 2008
  4. AAaron123
    Replies:
    0
    Views:
    1,124
    AAaron123
    Aug 8, 2009
  5. Mufasa

    Datagrid - caption - but at the bottom.

    Mufasa, Dec 30, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    155
    Mufasa
    Dec 30, 2008
Loading...

Share This Page