Formatting quoted code


/ Published in: CSS
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. }

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/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.