Force Preformated and Long Strings to Wrap with CSS
This technique works with text in <pre> tags and with long strings that aren’t broken up by spaces (like this_is_a_very_long_string). I struggled with this at work for a bit, then hit Google and found the solution at this informative site.
Here’s the code:
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
Just sub out the pre for the selector you’re working with if you need this for long strings.