Displaying Code Snippets: Wrap Long Lines with PRE Tag

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

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.

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

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

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.