How do I wrap text in a pre tag?
The answer, from this page in CSS:
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
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+ */
}
This works great to wrap text and maintain white-space within the pre
-tag:
pre {
white-space: pre-wrap;
}
I've found that skipping the pre tag and using white-space: pre-wrap on a div is a better solution.
<div style="white-space: pre-wrap;">content</div>
Most succinctly, this forces content to wrap inside of a pre
tag without breaking words.
pre {
white-space: pre-wrap;
word-break: keep-all
}