Wrapping Long URLs and Text Content with CSS


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

To wrap long URLs, strings of text, and other content, just apply this carefully crafted chunk of CSS code to any block-level element (e.g., perfect for <pre> tags):


Copy this code and paste it in your HTML
  1. .wrapped {
  2. /* wrap long urls */
  3. white-space: pre; /* CSS 2.0 */
  4. white-space: pre-wrap; /* CSS 2.1 */
  5. white-space: pre-line; /* CSS 3.0 */
  6. white-space: -pre-wrap; /* Opera 4-6 */
  7. white-space: -o-pre-wrap; /* Opera 7 */
  8. white-space: -moz-pre-wrap; /* Mozilla */
  9. white-space: -hp-pre-wrap; /* HP Printers */
  10. word-wrap: break-word; /* IE 5+ */
  11. /* specific width */
  12. width: 300px;
  13. }

URL: http://perishablepress.com/press/2010/06/01/wrapping-content/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.