Bug 47241 - line break immediately after tags should be ignored
Summary: line break immediately after tags should be ignored
Status: RESOLVED WORKSFORME
Alias: None
Product: konqueror
Classification: Applications
Component: khtml renderer (show other bugs)
Version: 4.0
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-30 21:32 UTC by gjditchfield
Modified: 2004-05-12 04:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Line break render as space prior to </a> (611 bytes, text/html)
2004-03-16 22:19 UTC, David P James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gjditchfield 2002-08-30 21:23:23 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           khtml
Version:           4.0 (using KDE 3.0.3 )
Severity:          normal
Installed from:    Unofficial RedHat
Compiler:          gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-112)
OS:                Linux (i586) release 2.4.18-10
OS/Compiler notes: 

A line break _immediately_ after a PRE tag should be ignored instead of being rendered as a blank line.
   The HTML 4.01 spec section B.3.1 http://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks
says
"SGML (see [ISO8879] section 7.6.1) specifies that a line break immediately following a start tag must be ignored as must a line break immediately before an end tag. This applies to all HTML elements without exception."  Konqueror from KDE 3.0.3 3.0.0 and 3.0.1 don't ignore the line break and render a blank line above the content of the PRE element.

Here's a sample HTML file.  Galeon 1.2.0 and Mozilla 0.9.9 render this correctly (the white spaces above the two PRE elements have the same height).
--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<p>The spacing above and below</p>
<pre>this one line PRE element</pre>
<p>should be exactly the same as the spacing above and below</p>
<pre>
this multiline PRE element
</pre>
<p>because whitespace before start tags should be ignored.</p>
</body>
</html

(Submitted via bugs.kde.org)
(Called from KBugReport dialog)
Comment 1 Daniel Naber 2002-09-25 22:41:28 UTC
I disagree: 1. khtml renders just like Mozilla does, 2. in XML (and I that's 
what HTML is becoming more and more) you cannot just ignore whitespace. On the 
other hand, we ignore the whitespace just after <li>, too, I think... 
 
Comment 2 gjditchfield 2002-09-26 05:34:53 UTC
Naturally, I disagree with comment #1. 1. When I view the HTML sample given above in Konqueror and in Mozilla 0.9.9, they do not render it the same way.  In Mozilla, the white spaces above the two PRE elements have the same height.  In Konqueror, the white space above the second PRE element is taller.  You can make this more obvious by adding a STYLE element containing "PRE { background-color: red; }" to the example: Mozilla renders each PRE as a line of text on a red background, while Konqueror displays the second as a line of text on a red background and with a blank red line above it. 2a. What HTML (and XHTML) may become is not the issue.  When a document's DOCTYPE says that it is HTML 4.01, KHTML must render it according to the HTML 4.01 specification. 2b. XML strictly avoids everything to do with the appearance of displayed documents.  The XML spec deals with the structure of the document, and leaves rendering issues to what it calls the "application".  The "White Space Handling" section of the XML spec says that the XML processor must pass white space characters through to the application, but it doesn't say that the application must display them on screen. 
Comment 3 Kai Lahmann 2003-06-14 03:33:25 UTC
read the HTML spec as "ignore for display" and be happy ;) 
..at least this IS a bug (in Mozilla as in konq). 
Comment 4 Stephan Kulow 2003-11-02 11:18:35 UTC
*** Bug 65546 has been marked as a duplicate of this bug. ***
Comment 5 David P James 2004-03-16 22:19:12 UTC
Created attachment 5244 [details]
Line break render as space prior to </a>

I see this a fair bit, ironically it usually involves a validation image...
typically, something like the following code is used (which is what is in my
test case):

<a href="http://validator.w3.org/check/referer">
<img src="http://www.w3.org/Icons/valid-html401" alt="ValidHTML4.01!"
title="ValidHTML4.01!" height="31" width="88">
</a>

KHTML displays an underlined linked space following the image.

I recommend that the summary be altered to "Line break immediately before and
after tags should be ignored".

As a web site creator, one can get around this by pasting exactly what the W3C
provides upon validation:

<a href="http://validator.w3.org/check/referer"><img
src="http://www.w3.org/Icons/valid-html401" alt="ValidHTML4.01!"
title="ValidHTML4.01!" height="31" width="88"></a>

But both are legit and the specs say both should be rendered the same way. I
have to confess that I believe the specs are a little inconsistent here and
that KHTML is more consistent, but nevertheless those are the specs and that's
how Gecko and Opera do it (don't know about IE).
Comment 6 gjditchfield 2004-05-12 04:26:17 UTC
Konqueror 3.2.2, from KDE 3.2.2 (contributed RPMs for SuSE 9.0) displays my example the way I think it should.
Comment 7 gjditchfield 2004-05-12 04:41:14 UTC
... but see bug 81393.