Fri, 17 May 2024


How to make text in <pre> tag wrap automatically on new lines?

By: Peter, NetArt Media
Sat, 13 November 2021

To do that, you could addthe following CSS styles for your <pre> tags -


<style>
pre
{
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
}
</style>

This code is tested and works in all major browsers.


Category: CSS
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox