Posted By

paul66 on 01/27/11


Tagged

css text wrap word-wrap white-space


Versions (?)

Formatting quoted code


 / Published in: CSS
 

URL: http://www.1stwebdesigner.com/design/snippets-html5-boilerplate/www.pathf.com/blogs/2008/05/formatting-quoted-code-in-blog-posts-css21-white-space-pre-wrap/

This snippet simply makes the text wrap when it reaches the walls of its container, in this case, the pre tag, whilst still preserving line breaks and white space cross browser.

  1. pre {
  2. padding: 15px;
  3. white-space: pre; /* CSS2 */
  4. white-space: pre-wrap; /* CSS 2.1 */
  5. white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
  6. word-wrap: break-word; /* IE */
  7. }

Report this snippet  

You need to login to post a comment.