Click to See Complete Forum and Search --> : seperation of text in a table data tag
chuckdawit
12-07-2007, 01:32 AM
If I have a table row tag and then a table data tag in a table tag like this:
<table>
<tr>
<td>name address city state zip country</td>
</tr>
</table>
Is there any way I can seperate the text in the td tag?
For example I want to give each word a certain width.
I have a string with an address (name address city state zip country)
and each field has a different width but I want to line them all up vertically so it looks nice. Can anyone help?
<table>
<tr>
<td>name</td><td> address</td><td> city</td><td> state</td><td> zip</td><td> country</td>
</tr>
</table>
WebJoel
12-07-2007, 08:20 AM
This works too:
CSS:<style>
#thisTable {}
#thisTable tr td {word-spacing:30px;}
</style>
HTML:<table id="thisTable">
<tr>
<td>This is some text in a TD cell</td>
</tr>
</table>
That only works, though, if you have one-word entries, though, right? If the city was "San Francisco," "San" would be 30px away from "Francisco.":o
WebJoel
12-10-2007, 10:44 AM
That only works, though, if you have one-word entries, though, right? If the city was "San Francisco," "San" would be 30px away from "Francisco.":o I don't understand. This seperates words in a multi-word sentence. It's similar to "letter-spacing' which changes the default kern, but this spaces-out the actual words. (I admit though that I had to try this, and it works). :)
Similar to 'text-align:justify;' except that you get to choose how much 'space' between the words.
Yeah, but a name like "San Francisco" is actually two words "San" + "Francisco"
Check it out:
<p style="word-spacing: 30px;">San Francisco</p>
So, the browser thinks of this as two words, not one name. Thus, keeping the name of the one field (city) together isn't possible. It would be the same for a street address like "Oak Street" or "1234 Oak Street" because the browser is just detecting the spaces and separating the "words" by 30px, irrespective of the text string.
KDLA
chuckdawit
12-10-2007, 12:46 PM
This seperates words but not strings.
I'm placing in strings (ex. address might be 123 robin dr. , city might be corta madera) so I don't want a space between each word. I want a space between each string. And no more than a certain width.
In any case, the "correct" answer is surely KDLA's first suggestion: putting each heading in a separate column, i.e. <td>. This has the big advantage over other methods that it actually works, and the small advantage that it is easy. If you don't like the way the borders come out, you may need nested tables and some CSS.
In any case, the "correct" answer is surely KDLA's first suggestion: putting each heading in a separate column, i.e. <td>. This has the big advantage over other methods that it actually works, and the small advantage that it is easy. If you don't like the way the borders come out, you may need nested tables and some CSS.
Nested tables? Not needed. Only CSS.
Nested tables? Not needed. Only CSS.
I was thinking that perhaps the reason why the original poster did not use multiple columns to start with was that he had some more complex formatting requirements, in which case he might need to use nested tables. Like, if he wanted the city, state, zip etc to not have borders between the cells, but to have borders between these and other cells in the row, then nested tables are the easiest way to do it. (Yes, I'm aware it could be done purely with CSS, but depending on the details, that's usually a pain.)
Anyway, I'm just speculating about what the "real" problem is. If the original post was the full story, then none of the above is relevant, and neither nested tables nor CSS is required, just plan HTML table tags.
WebJoel
12-10-2007, 04:49 PM
Yeah, but a name like "San Francisco" is actually two words "San" + "Francisco"
Check it out:
<p style="word-spacing: 30px;">San Francisco</p>
Ahhh! -I see what you are saying now!
*I'd* just go .normal {word-spacing: normal}and<p style="word-spacing: 30px;"><span class="normal">San Francisco</span> is a very nice city!</p>and keep regular expressions like "San Francisco" in the normal kern for typed words (typically, something like 5px between words??).