Open Bug 484659 Opened 15 years ago Updated 2 years ago

Use white-space: pre-wrap in html.css to wrap long lines of preformatted text

Categories

(Core :: Layout, defect)

defect

Tracking

()

UNCONFIRMED

People

(Reporter: bugmail-mozilla, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.0.7) Gecko/2009030423 Ubuntu/8.10 (intrepid) Firefox/3.0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.0.7) Gecko/2009030423 Ubuntu/8.10 (intrepid) Firefox/3.0.7

Long lines inside a <pre> block aren't wrapped because of the following code in html.css:
  xmp, pre, plaintext {
    (...)
    white-space: pre;
    (...)
  }

This causes a horizontal scrollbar to appear on sites with long lines of preformatted text such as http://fr.openoffice.org/servlets/ReadMsg?listName=users&msgNo=75814
It makes the text harder to read as you have to scroll horizontally on each line.

CSS 2.1 introduced a new value of white-space: pre-wrap. This values allows long lines to be wrapped if they are too long. It was implemented in bug 261081. 

Reproducible: Always

Steps to Reproduce:
1. Go to page http://fr.openoffice.org/servlets/ReadMsg?listName=users&msgNo=75814
2. Resize your window to a width of 1280px or less
Actual Results:  
A horizontal scrollbar appears. Text is hard to read.

Expected Results:  
Lines should wrap. Text would be easier to read.

HTML specification for pre <http://www.w3.org/TR/html401/struct/text.html#edef-PRE> states that UA "May disable automatic word wrap". Keeping lines intact isn't mandatory nor recommended.

I think the value "pre" of white-space was used because there were no alternative in CSS 2.0, because pre-wrap was introduced in CSS 2.1. However, now that a better alternative exists, I think we should use it.

However, it may have side-effects on websites relying on pre lines not breaking. It should be noted that all other browser (Opera, Konqueror, IE) seems to keep lines intact.
Component: General → Layout
Product: Firefox → Core
QA Contact: general → layout
Attachment #368787 - Flags: review?(roc)
Comment on attachment 368787 [details] [diff] [review]
proposed patch for html.css

This would break compatibility with other browsers. We don't want to do that.
Attachment #368787 - Flags: review?(roc) → review-
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: