How to apply word wrap to text files viewed in Mozilla Firefox

As mentioned before, many of the public ICANN meetings have transcripts available within hours after the meetings as text files. However, a disadvantage with viewing the ICANN New Delhi 2008 meeting transcripts with Mozilla Firefox such as the transcript for “Workshop: Update on Internet Governance” held on February 11th, 2008 is that the length of the lines of text are too long for the browser window requiring you to scroll left and right to read the transcript which gets confusing with the likely result that you stop reading the transcript online or try to insert the text in a word processor or text editor to word wrap the text.

If only there was a way to word-wrap the text in the browser window…………..

Well, there is an easy solution for Mozilla Firefox users which I discovered, thanks to Tero Karvinen’s article “Making preformated <pre> text wrap in CSS3, Mozilla, Opera and IE”

To word wrap text in text files displayed in Mozilla Firefox :

  1. Locate the sub-folder called chrome in your profile folder. See on how to find where Mozilla Firefox stores the profile folder for different operating systems.
  2. In this chrome subfolder, edit the text file “userContent.css” with a text editor (such as Notepad). Typically, this file does not exist by default. There is a userContent-example.css in this chrome sub-folder which you can rename to userContent.css
  3. Add the following line to userContent.css :
    pre { white-space: -moz-pre-wrap !important; }
  4. Save the file, and restart Firefox for the changes in userContent.css to take effect.

With this change, any text files you view in Mozilla Firefox will automatically be word-wrapped so that you don’t have to scroll left and right to read the text file.

12 thoughts on “How to apply word wrap to text files viewed in Mozilla Firefox”

  1. Here’s a simpler solution: Press Ctrl+U. Enable View > Wrap Long Lines if necessary. Done.

  2. Rahul : your method is simpler for viewing one text file. If you have multiple text files open (each in its own tab), viewing the source for each would result in multiple taskbar buttons in the Windows taskbar for each view source window.

  3. Thank you so much for posting this. I’m surprised that Firefox does not automatically wrap long lines. Google Chrome does it off the shelf. The work around did the job.

  4. Since this looks like the most popular site for this trick on Google, I just wanted to mention for people in the future that come here: the code as given won’t work for Firefox 3.5 or later, since -moz-pre-wrap was deprecated. Instead, replace that with pre-wrap in those versions.

  5. This is what worked for me.

    I found the profile folder of Firefox, then in the sub-folder of chrome, I found a file called userContent-example.css. I opened it in a text editor and saved it to the same folder using the filename userContent.css.

    Then I added the following lines:

    /* Word Wrap Pre-formatted Text*/
    pre { white-space: pre-wrap !important; }

    I saved the file, restarted Firefox, and the text wrapped like I wanted it to. I am using Firefox 3.6.12.

Comments are closed.