Search code examples
htmlcssword-wrap

Word Wrap a Div, all on a single line


I have a string in a div: Test: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Using a the word_wrap CSS class found on Stack Overflow,

/* Source: http://snipplr.com/view/10979/css-cross-browser-word-wrap */
.wordwrap { 
white-space: pre-wrap;      /* CSS3 */   
white-space: -moz-pre-wrap; /* Firefox */    
white-space: -pre-wrap;     /* Opera <7 */   
white-space: -o-pre-wrap;   /* Opera 7 */    
word-wrap: break-word;      /* IE */
}

it appears like this:

Test:
AAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA

How can I wrap it so Test: and the A's are on the same line?


Solution

  • Use a &nbsp; instead of a regular space:

    Test:&nbsp;AAAAAAAAAAAAAAAAAAAA