Monday 27 August 2007

Background for Table Caption in Opera9

If you set your CSS to include "display: inline" for a table, then Opera9 will screw up any background colour (or color) for the tag - the color will expand to fill the maximum available width - far wider than the table!

The following document shows the problem (if you view it in Opera 9):



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<style type="text/css">
<!--
#table2 {
display:inline
}
.c1{
background-color:yellow;
}
.w1{
width: 6em;
}
-->
</style>

</head>

<body>
<p>table 1 - without the INLINE declaration:</p>
<table id="table1" border="1" cellpadding="0" cellspacing="0">
<caption class='c1'>Here is a caption, which goes on and on and on</caption>
<tr>
<td class='w1'>Cell 1</td>
<td class='w1'>Cell 2</td>
</tr>
</table>
<p>table 2 - without the INLINE declaration:</p>
<table id="table2" border="1" cellpadding="0" cellspacing="0">
<caption class='c1'>Here is a caption, which goes on and on and on</caption>
<tr>
<td class='w1'>Cell 1</td>
<td class='w1'>Cell 2</td>
</tr>
</table>
</body>
</html>