CSS Assorted Issues
[...]
How to wrap a text (say in a <pre> tag) using CSS
Say you want to wrap a text in a <pre> tag that is too long. Yet, text in <pre> tags doesn’t wrap by default.
You may do some of the following:
- Set
white-space: pre-line;: this tells the browser to honor the line breaks in your HTML source code while still wrapping text naturally. • display: block - Use the CSS
overflow-xproperty set to "auto" which adds the scrollbar automatically when the contents are overflow. - At last, use the main
word-wrapproperty which is set to "break-word" so that words that exceed the width of the container will be arbitrarily broken to fit within the container’s bounds.