3

I am putting a border and outline around a table. It works fine in latest IE and Firefox, but Chrome is putting the outline around my captions as well. In IE and Firefox the outline only displays around the table, which is what I want. How to fix this in Chrome?

Demo: http://jsfiddle.net/R7aTq/17/

HTML

<table align="center" cellspacing="1" class="homepagemodule  report" id="trades">
    <caption><span>Pending Trades</span></caption>
    <tbody>
        <tr>
            <th>Currently Outstanding Trades</th>
        </tr>
        <tr class="oddtablerow">
            <td>
                <ul>
                    <li>0 trades proposed by me to others</li>
                    <li>0 trades proposed by others to me</li>
                    <li><a href="http://football21.myfantasyleague.com/2013/options?L=56019&amp;O=05">View trades now</a></li>
                </ul>
            </td>
        </tr>
    </tbody>
</table>

CSS

Table caption appears inside outline in some browsers, outside in others.

caption {
    color: #333;
    font-weight: 400;
    font-size: 12pt;
    background: none;
    text-align: center;
}
.report {
    width: 300px;
    background: #ccc;
    border: 2px solid #fff;
    outline: 1px solid #000;
}
3
  • 1
    Do you have an image of what it looks like for you? seems fine to me
    – chriz
    Commented Mar 26, 2013 at 14:03
  • This affects Chrome, Safari, and Opera. Commented Mar 26, 2013 at 14:13
  • The decision of whether a table caption should appear inside or outside of a table outline appears to have been left up to individual browsers to choose. It appears to be very consistent for each browser though, and reasonable either way. Personally, I find it more appropriate to have the caption inside the outline, as is the case with Chrome, since the caption is a part of the table. Commented Mar 26, 2013 at 16:22

1 Answer 1

1

You need to take the outline and move it to tbody. Outline is used to show focus on an element, the whole element. Chrome sees the whole element as table which caption is a child of so it puts the outline around all of it.

Remove outline from your report class and add a new class or new style to tbody that sets the outline.

EDIT

Add in display:block; that seems to fix it.

updated the proof: http://jsfiddle.net/R7aTq/83/

Or you could get rid of tables all together and use divs like in this fiddle:

non-table version: http://jsfiddle.net/R7aTq/130/

9
  • The styling isn't the same. There's no longer a 2px gap between the outline and the background color (the white border inside the outline). Commented Mar 26, 2013 at 14:39
  • thx , i tried the tbody before posting and didn't work in Chrome
    – MShack
    Commented Mar 26, 2013 at 14:44
  • Jake retried again, it works in Chrome now, but leaves a larger outline in FF and IE jsfiddle.net/R7aTq/80
    – MShack
    Commented Mar 26, 2013 at 14:54
  • Jake looks good in IE, Chrome and FF , i don't have Safari or Opera to check...anyone ? I see you gave the tbody a class of outline, i retesting using .report>tbody , works fine without having to add that class to all my tables. Thanks ! I tried to mark you up , but says i need 15 reputation here....
    – MShack
    Commented Mar 26, 2013 at 15:14
  • 1
    @JakeZeitz: It's worth mentioning that this isn't the type of content that's really appropriate for an HTML table anyways. Tables are best used for data grids. Arguably, little or nothing is gained by using a table here. Commented Mar 26, 2013 at 16:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.