views:

40

answers:

2

I know about non-breaking spaces but I've got the opposite problem and Google doesn't even find anyone else asking the question.

I have a piece of text: <option A>/<option B>/<option C> (the number of options is variable) that I want to break only at the slashes. Keeping it from breaking elsewhere is trivial--replace the spaces with non-breaking spaces. What I'm stumped on is permitting it to break after the slashes. Do I just have to insert an extra space after the slashes even though that won't look as good?

+4  A: 

You can use the <wbr> tag to allow the browser to break at the slashes:

<option A><wbr>/<wbr><option B><wbr>/<wbr><option C>
Annie
Thanks. That's exactly what I was after. I figured there should be something like this but I was coming up dry on Google.
Loren Pechtel
Too bad it's not standard. +1 anyway; it *should* be standard.
Norman Ramsey
+3  A: 

Use a Unicode Zero Width Space (U+200B). You can enter them directly as characters — optionA​/​optionB​/​optionC — or alternatively, since you can't really see the zero-width-spaces there, as character references: optionA&#x200B;/&#x200B;optionB&#x200B;/&#x200B;optionC.

bobince
Note that if you use this approach, the zero-width characters get copied when users copy and paste the text.
Annie