How to Wrap Text in an Html PRE tag

A CSS technique for Wrapping Preformated text in the PRE tag.
by

To force long text lines to wrap in an HTML <pre> tag, you can use CSS code to wrap the text. The word-wrapping CSS code below should work to wrap long lines of text within the <pre> tag, in IE, Firefox and Safari...   you may want to test the browsers for yourself just to make sure though.

With that said, simply add the following snipet of CSS code to your main CSS file:

pre
{
    overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
    white-space: pre-wrap; /* css-3 */
    white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
    white-space: -pre-wrap; /* Opera 4-6 */
    white-space: -o-pre-wrap; /* Opera 7 */ /* width: 99%; */
    word-wrap: break-word; /* Internet Explorer 5.5+ */
}
 


0
0

Add your comment

by Anonymous - Already have an account? Login now!
Your Name:

Comment:
Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your comment will appear after being approved.

Related Posts


This tutorial will teach you how to use the SUM function in Microsoft Excel to add column values together in order to calculate a total amount.  more »

In the code below, you will be able to find the baseUrl of your website using javascript. The following javascript code will work when used on your localhost or when it's used in a live site (finds the root url of the domain address). Just add this...  more »

Here's a quick tip on how to get the Taskbar in Windows 7 to become visible while watching a flash video (YouTube, Vimeo, etc.) in full-screen mode. To get the taskbar to show while still in full-screen video mode, simply press the Windows (logo ÿ)...  more »

I recently ran into an issue with the ELMAH Error logger Table getting way TOO Big in my SQL Server database. The table row size in the ELMAH_Error table had over 200,000 rows. This was way more than I ever needed to look at, and was causing other issues...  more »

In this tutorial you will learn how to backup the Registry on a Windows computer. Having a backup of your registry is extremely important if you plan to make any manual settings changes to the Registry, because if you make a mistake while messing around...  more »

The AjaxFileUpload control that's part of the AJAX Control Toolkit, works great for easily uploading multiple files at once. However, it gets a little tricky if you want to update an UpdatePanel after all the files have finished uploading, especially if...  more »

The Windows Task Manager can be used to start programs, to end running applications, to start or to end processes, as well as to view a dynamic display of your computer's performance. To be able to start the Windows Task Manager, you can use any one of...  more »

The ScanDisk utility that was in previous versions of Windows is no longer available in Windows XP. Not to worry because you can now use the Error-Checking tool to check the integrity of your hard disk.  more »

In this quick tip, you'll learn how to open the Windows Explorer in Windows 7. Move your mouse cursor over the windows Start button and right-click. In the menu that pops up, click on Open Windows Explorer. The Windows Explorer window should open up, and...  more »

Email messages sometimes are sent with images attached, which make saving the images to your computer fairly easy. However, sometimes the pictures are only embedded within the actual email message without the ability to download any attachments. This can...  more »

Having strong yet easily memorized passwords is crucial to protecting your personal information on the internet or your computer. Most people use passwords for many day to day online activities - checking your e-mail, paying your bills, logging into your...  more »

At some point you may need or want to test your computers memory ram to make sure it is work correctly. In Windows 7, you can easily test your memory or RAM using the built in Windows Memory Diagnostic Tool. To do this in Windows 7 follow these steps: In...  more »