We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

j_junyent on 01/13/08


Tagged

wrap pre snippets


Versions (?)


Who likes this?

6 people have marked this snippet as a favorite

iTony
jonhenshaw
basicmagic
SpinZ
arala22
stoker


Displaying Code Snippets: Wrap Long Lines with PRE Tag


Published in: CSS 


URL: http://labnol.blogspot.com/2006/10/html-css-trick-for-displaying-code.html

The tag that defines preformatted text is the only tag in HTML that respects and preserves whitespaces like line-breaks, blanks, tabs and multiple spaces between words. Whatever is enclosed inside the pre element will be displayed as-it-is on the web browser.


  1. pre {
  2. white-space: pre-wrap; /* css-3 */
  3. white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
  4. white-space: -pre-wrap; /* Opera 4-6 */
  5. white-space: -o-pre-wrap; /* Opera 7 */
  6. word-wrap: break-word; /* Internet Explorer 5.5+ */
  7. }

Report this snippet 

You need to login to post a comment.