Search This Blog

HTML: Word wrap in <pre>

To enable word wrap inside <pre> you need the following CSS style:
pre
{
 white-space: pre-wrap; /* CSS2.1 compliant */
 white-space: -moz-pre-wrap; /* Mozilla-based browsers */
 white-space: -o-pre-wrap; /* Opera 7+ */
}

Example:
before applying white-space:pre-wrap:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
after applying white-space:pre-wrap:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

No comments:

Post a Comment