Forum Moderators: open

Message Too Old, No Replies

Preventing line breaks at hyphens

Is there any way to prevent a line of text from breaking at a hyphen?

         

Chick

4:10 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



I want to display a line in a table cell that contains an embedded hyphen, but prevent the line from breaking at the hyphen.

Example:

Inside a table cell, just a simple <td>ABC-D</td>, but I do not want the output to come out as

ABC-
D

Is there any way to prevent this?

BlobFisk

4:26 pm on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use CSS and apply no wrapping to table cells - although this will try to prevent all wrapping from table cells. This is the CSS equivalent of the <nobr> html tag.

HTH

Chick

4:45 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



Thank you, BlobFisk, but unfortunately, I don't want to prevent all wrapping, just prevent the break at hyphens.

I am hoping there is some option to make a hyphen into the equivalent of a letter or number so it isn't treated as a gap in a word. I've looked in places like css and html documentation with no luck, so maybe there isn't a way to do it, but I thought I'd ask here as a last resort.

topr8

4:45 pm on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



or just use the same css suggested but wrap the line you don't want to wrap within <span> tags

Chick

4:58 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



OK, this sounds promising ...

Here's what I have

<TD><SPAN class=nowrap>ABC-D</SPAN></TD>

and in the CSS

.nowrap td {NOWRAP}

and it's not working. My guess is that the CSS line is not right?

I don't want to prevent wrapping on the entire cell, just on the particular word with the hyphen.

pshea

5:32 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



Try this solution in your code:

some <NOBR>hyphenated-name</NOBR> here

Chick

5:48 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



YAY, PShea, that worked!

Thanks muchly everyone, I always get good answers and fast responses here, I love this site!