Forum Moderators: open

Message Too Old, No Replies

CAPTION align="left" - display problem in Firefox

At top of table in IE - to left of table in Firefox

         

kiwibrit

12:14 pm on Nov 26, 2005 (gmt 0)

10+ Year Member



If I use

<CAPTION align="left">

for a table, it displays where I want it - aligned left, at the top of the table.

But it displays to the left of the table in Firefox.

Removing "align left" centres the caption at the top of the table, for both IE and Firefox.

Is there any way of having the caption displayed aligned left, at the top of the table, in both IE and Firefox?

kaled

1:48 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I never use a <caption> with tables. Instead, merge cells together, e.g.
<tr><td colspan="2">place caption here</td></tr>

Having done that, you may use CSS textalign.

Kaled.

Robin_reala

1:50 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you read the specs this is actually what it's supposed to do. @align is overloaded for caption elements to mean the side of the table to put it on:

[w3.org ]

Deprecated. For visual user agents, this attribute specifies the position of the caption with respect to the table. Possible values:

* top: The caption is at the top of the table. This is the default value.
* bottom: The caption is at the bottom of the table.
* left: The caption is at the left of the table.
* right: The caption is at the right of the table.

Luckily we can easily achieve what you want using CSS. For example:

caption { text-align: left; }

(as an aside, see the big deprecated in the above quote? This usually means that tere's a way to get the same effect using CSS alone instead of presentation HTML. And indeed this is true - the CSS caption-side property is a direct replacement for this. Not supported by IE, but then seeing as this original @align wasn't supported we're no worse off.)

kiwibrit

4:41 pm on Nov 26, 2005 (gmt 0)

10+ Year Member



Thanks both.

<caption style="text-align:left">

cracks it - both in IE6 and Firefox.

I'm using <caption>, as I think it's best for accessibility