Center Table but not Caption!

S

sorry.no.email

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.
 
M

Martin Jay

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;
}
 
S

sorry.no.email

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top