views:

43

answers:

3

Is there any way to prevent '?' from being treated as white-space-like in HTML/CSS? Is this default behavior, or am I doing something wrong?

I have a div that holds a very long URL (the length is dynamic). I want the URL to treat the question mark as any other character and not force a line break at that character, but I don't want to use white-space:nowrap;, since that will cause the entire line to overflow out of the div, which is not a desired behavior.

The desired behavior is for the text to wrap at the end of the div onto the next line, as it would if it weren't for the question mark. alt text

It likely doesn't matter, but here are their CSS properties:

 a{color:green; font-weight: bold;} .ycpreviewbox{ margin: 0 auto; padding: 2em; background-color: #C7E2ED;} .

Here is how it behaves with a shorter URL: alt text

A: 

You might consider inserting a space or linebreak after a number of characters instead of relying on the browser to decide where to break your string.

Zac
A: 

Try the nobr tag.

Jerome
+2  A: 

In HTML5 you can also use <wbr> for suggesting line breaks...
maybe this could help, by telling the browser where it should break the line, instead of letting it decide by itself...

dolma33
With with this. Not the most convenient solution, but it works. Thanks!
yc