I'm having trouble with TD widths. They seem to be being ignored. I have some code like this:

<table align="center">
	<tr>
		<td align="center"><img src="../images/spacer.gif" width="1" height="5" alt="" class="bg-spacer" /></td>

</tr>
<tr> 
	<td valign="top" class="text-msg-info">
		This is a message.
</td>
</tr>
<tr>
	<td align="center"><img src="../images/spacer.gif" width="1" height="5" alt="" class="bg-spacer" /></td>
</tr>
</table>

and the css for text-msg-info is:

.text-msg-info {
	background-color	: #FFEBCB;
	border		: 1px solid #F98537;
	color			: #C00000;
	font-style		: italic;
	padding		: 5px;
	text-align		: center;
	width			: 80%;
}

but the TD is always the full width of the table instead of 80% of the table's width.

Could anyone suggest how I could get this working, please?

Debbie

    i would start by doing away with the dashes in your css class definition. most browsers dont like it. try changing this;

    .text-msg-info

    to this;

    .textmsginfo

      I don't think that would do much as all the attributes are being rendered properly, just not the width one.

      So far, I've had no problems with any browsers recognising hyphens in class names.

      Debbie

        I'd also recommend finding an HTML/CSS forum to ask in, instead of a PHP one. You'll find a higher proportion of experts there, and it's where other people with similar problems will think of looking first (and hence find whatever solution you get).

          Found the solution at last. Thought I'd let you all know:

          One TD always takes up 100% of a table's width, so you need at least 3 TDs to achieve this - the two outer ones just to ensure the middle one is centered:

          <table align="center" border="1">
          <tr>
          	<td>&nbsp;</td>
          	<td valign="top" class="text-msg-info">
          		This is a message.
          	</td>
          	<td>&nbsp;</td>
          </tr>
          </table>
          

          Hope that helps anyone who has a similar problem.

          Debbie

            yeh why dont you add wrap too ?

              Write a Reply...