views:

629

answers:

6

A   character is a space which doesn't allow for line breaking.

<p>lorem ipsum here&nbsp;are&nbsp;some&nbsp;words and so on</p>

| lorem ipsum                |
| here are some words and so |
| on                         |

What's the opposite of that? That is, a character which is NOT rendered as a space, but CAN be used for line breaking.

<p>foo supercalifragilisticexpialidocious bar</p>
<!--   put char here ^   and here ^ -->

|foo supercalifragi |
|listicexpiali      |
|docious bar        |

or with wider size:

|foo supercalifragilisticexpiali   |
|docious bar                       |

I'm aware of the soft-hyphen character, but for my purposes, I specifically do not want a hyphen added at the break.

+49  A: 

You want the unicode character ZERO-WIDTH SPACE (\u200B).

You can get it in HTML with &#8203;.

Anon.
I tested this, it does not produce a line break in Firefox 3.5.7.
Noon Silk
It's not meant to produce an explicit linebreak. It's meant to indicate a point where the line *can* be wrapped if it's too long to fit in wherever it's supposed to go.
Anon.
Ah, well in that case, it *does* work, and nicely done.
Noon Silk
this is way cool. thanks!
Epaga
IE6 and Opera (not sure the version, but a recent one) both show this character as a "missing unicode" glyph, unfortunately.
nickf
Well that's IE6 for ya.
Mike Weller
@Mike ...and Opera...
nickf
A: 

I think what you are looking for is <br>.

<p>foo supercalifragi <br>listicexpiali <br>docious bar</p>
Mike Curry
That won't work for the second use case ("or with wider size:")
bguiz
Mike: I also misread his post; he wants optional line-breaking, not a specific break (i.e. breaks based on size, at this location).
Noon Silk
+24  A: 

There also is the little-know wbr tag, which lets the browser to decide wether to break the line or not.

Matt Hampel
It should be noted that this is non-standard, and not supported in all browsers.
Brian Campbell
@Brian, check the quirksmode link fredden posted.
nickf
If it's good enough for Facebook, it's good enough for every one ;-)
Martin Bean
+1  A: 

use <wbr>.

Here Be Wolves
+10  A: 

There's a nice page over at quirksmode.org that answers this question quite nicely IMHO. http://www.quirksmode.org/oddsandends/wbr.html

In short: use <wbr /> or &#8203; (or &shy; but you mentioned you don't want the dash).

fredden
Not all of these possibilities are supported by all browsers. I guess ​ is the best solution as most browsers should be able to recognize Unicode.
AndiDog
and IE6 users get an ugly glyph apparently... my heart weeps.
nickf
A: 

theres a lot of discussion about this but it has become more or less standard to use &shy;

Joe Hopfgartner