Closed Bug 15430 Opened 22 years ago Closed 22 years ago

White-space: on body causes error in vertical positioning of content


(Core :: CSS Parsing and Computation, defect, P3)

Windows 98





(Reporter: ian.graham, Assigned: peterl-retired)




The referenced document is really simple, and simply assigns
white-space: pre to the body element:

<title> Problems with white-space vertical spacing -- </title>
<style> <!--
body  {/* font-size: 16pt; */  white-space: pre; }
p     {font-family: courier new;  background-color: yellow;}
--> </style>
<p>An example       paragraph to illustrate font property inheritance (or
lack thereof) </p>
<p>An example       paragraph to illustrate font property inheritance (or
lack thereof) </p>

This results in a large space left at the top and bottom of the page, and an
enlarged margin between the two paragraphs. This spacing is dependent on
the body font-size (commented out in the example). This space is not a
margin -- at least it cannot be eliminated using explicit margin properties
on the p or body elements.

This is on the M9 build, Win 98.
I don't see a large space at the beginning as you describe (Linux,

I think the gap between the paragraphs should be expected, because each of the
paragraphs has a 1em margin, and these are separated by a blank line from the
whitespace: pre rather than collapsing.  Or perhaps they should still
On Win98 the first paragraph is about 4-5em down from
the top of the viewport, and the bottom of the document is about the same
distance down from the last paragraph... and I don't think there are enough
newlines/line feeds to cause that.

I believe that with white-space: pre the space between the paragraphs should
not collapse, so that might have explained the extra space there..
Unfortunately, if I put the paragrah end and start tags on the same line
it does not change the paragraph separation -- I added 2 new paragraphs at
the end of the example, that are entirely on the same line (no line breaks),
and I still see a 2em (or more) space between the paras.

So there is something wrong, at least on M9.  Maybe it's fixed on your build?
Closed: 22 years ago
Resolution: --- → INVALID
All white space becomes significant because of the white-space:pre on the body
(white-space is inherited). THIS INCLUDES SPACES! Therefore there is one blank
line at the top of the document before the first <p>, and there is one between
the paragraphs. (There is also one after the last paragraph, but you cannot see
it without putting a border on the body element.) These turn into anonymous
inlines, thus preventing the margins from collapsing.

The first of these newlines should actually be ignored, this issue is covered
by bug 2750.

The bug reported here is not a bug, however. Marking INVALID.

Even if you have only one space between the paragraph tags:

   bla bla</p> <p>bla bla

...there will be an anonymous inline.

dbaron: On W98 there is a 1em space before the first paragraph. This isn't the
margin, the first element never has a margin (search ua.css for 'first-node').
If the first newline was correctly collapsed away, the gap between the top of
the page and the yellow would be 8px, just like on the left and right.
Is it not there on linux?

ian.graham: Yup, on the latest builds the gap at the top is a lot less because
we now remove the top margin. On your build you are seeing the first blank line
caused by the white-space:pre, and then the 1em margin on the paragraph. Because
the 'first-node' ignores leading whitespace (even if it generates anonymous
inlines) in the latest builds we are dropping the margin-top.
That makes sense. I made up another test case
( that
removes all newlines between elements and sets paragraph and body
vertical margins to zero. I'll test this on the next build, and
verify that the first paragraph is flush with the top of the viewport.
The extra whitespace at the top may have been caused by bug 12298/bug 13688,
fixed 1999-09-21.
Sorry, bug 12998 (not 12298).
Verified invalid
You need to log in before you can comment on or make changes to this bug.