...

View Full Version : Floating text in table cell



nick2price
06-19-2012, 10:42 PM
Hi. I have the following

<tr>
<td>business class flights to <strong>Abu Dhabi</strong> from <strong>1185</strong></td>
<td>business class flights to <strong>Miami</strong><span>from <strong>1365</strong></span></td>
</tr>

At the moment, all the text starts from the left. The reason I have "from 1365" in a span because I wanted this part of the text to float on the right hand side of the table cell. Span doesnt seem to do the trick, so I was wondering what other options were available.

Cheers

Nick

felgall
06-19-2012, 10:50 PM
ou can't float inline content as it has to stay inline with the surrounding content.

The simplest solution would be to make it a separate column.

Most of that text should be outside the table anyway - the first column should contain the destination and the second column should be the amount. These headings should be displayed in the <thead> of the table in <th> tags. That way your table will be defined correctly and displaying proper tabular data.

The "Business Classs flights to:" part should go in the <caption>

nick2price
06-19-2012, 11:11 PM
I actually got it working, but I dont know if its good. What I ended up doing is applying a class to the span tags, and for the css for that class, I used float:right. Seems to do the trick.

felgall
06-19-2012, 11:37 PM
I actually got it working, but I dont know if its good. What I ended up doing is applying a class to the span tags, and for the css for that class, I used float:right. Seems to do the trick.

Possibly in some browsers.

Adding more bad code to the bad code you already have isn't going to work in all browsers.

nick2price
06-19-2012, 11:46 PM
Well if there is a better way then I would like to try and do it. Problem is I dont really know the way you suggest. Do you know of any examples of this type of thing?

Nick

felgall
06-20-2012, 03:06 AM
I'd start with the following and then adjust the appearance using CSS.


<table>
<caption>Business Class flights to:</caption>
<col id="dest">
<col id="cost">
<thead>
<tr><th>Destination</th><th>Cost from:</th></tr>
</thead>
<tbody>
<tr>
<td>Abu Dhabi</td><td>1185</td>
<td>Miami</td><td>1365</td>
</tr>
</tbody>
</table>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum