Bug 131031

Summary: <pre> line-breaking (and hyphenation) rules overridden by inherited hyphenation
Product: WebKit Reporter: Matthew Tylee Atkinson <matkinson>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: bfulgham
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
test case none

Description Matthew Tylee Atkinson 2014-04-01 05:42:44 PDT
Convention amongst browsers is that the <pre> element should not have any line wrapping by default, and browsers should not add any extra characters to its contents.  Even if hyphenation is set on the <body>, it should not be applied to the <pre> element unless the user has explicitly styled the <pre> element (justification for this can be found below).

This appears to be related to bug 67770 -- https://bugs.webkit.org/show_bug.cgi?id=67770 -- but is not quite the same situation (the applicable CSS is different), hence I am reporting it as a separate bug; hope that's OK.

// Test Case (attached)

The following browsers didn't wrap or hyphenate the contents of the <pre>.

 * IE 11
 * Firefox 28
 * Chrome 33

In the following browsers, wrapping and hyphenation inside the <pre> occurred.

 * WebKit Nightly r166560 (2014-04-01)
 * Safari 7.0.2
 * Safari on iOS 7.1

// Expected Outcomes

1. The <pre> element should not introduce line-breaks as a result of hyphenation being set on a parent element.

2. The <pre> element should ignore hyphenation set on a parent element.

// Justification for desired behaviour

Why ignore an inherited hyphenation style?  Because <pre> is meant to contain "preformatted text" according to the spec [1], which implies no further formatting is desired on the part of the content author.

This also applies to line-breaks, as '<pre><code>...' is often used for computer code samples, whose authors expect that code could be copied and pasted from the browser; extra line-breaks would cause code errors in some cases.  The spec also cites examples of ASCII art and free-form poetry, which would be affected similarly.

[1] http://www.w3.org/TR/html/grouping-content.html#the-pre-element
Comment 1 Matthew Tylee Atkinson 2014-04-01 05:43:23 PDT
Created attachment 228276 [details]
test case
Comment 2 Brent Fulgham 2022-07-13 17:13:41 PDT
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.