11
th
Jan
The CSS Pre Wrap Trick
Quick CSS Tip on how to make the pre tag wrap the text inside of it.
I have had to use this only twice in my career as a web developer… but both times this saved my life. Here is the problem, we need to use the pre tag sometimes to have preformatted text display the way it should… but the pre tag makes it not warp (display on a new line if the width is less than the text on the line). So here is the fix for all browsers.
pre {
white-space: pre-wrap; /* css-3 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5+ */
white-space: -moz-pre-wrap; /* Older Versions of Mozilla */
}
Enjoy,
Related Articles
Most Popular
- Top 10 CSS Snippets
- Web Application Interface Design Guide
- 10 Important Tips and Tricks about using DreamWeaver
- 8 Tips and Tricks on Developing Usable Websites
- Top 10 jQuery Modal Box Plugins
- Fancy Glowing Login Box
- Star Rating For Expression Engine (using jQuery)
- Interview with Jason M. Putorti - Deux
- 7 Design Elements and Techniques that will make your Website stand OUT!
- jQuery for uttermost beginners (video)




