Closed Bug 298370 Opened 20 years ago Closed 20 years ago

CSS floating div or span has extra padding at top and bottom

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: sethlivingston, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 Adding the CSS float property to a div or span adds extra padding at the top and bottom of the div or span. The padding can't be removed or reduced. Reproducible: Always Steps to Reproduce: Reproduced in attached HTML file. Actual Results: The floating element has extra padding at the top and bottom. Expected Results: Shown zero padding at the top and bottom.
Well, the <p> tag has a default margin-top and margin-bottom of 1em, so that's why you see the extra space.
This is INVALID. The behaviour is completely correct. If you wish to remove the margins, remove them from the <P> inside the <DIV> (see also collapsing margins in the CSS 2.1 spec <http://www.w3.org/TR/CSS21/box.html#x22>). The margin of the <P> in the left col collapses into the <DIV> and the <BODY>, resulting it is visually appearing as if the margin was on the <BODY> (which already has a similar margin, thus it looks fine). In the right col, the margin of the <P> can not collapse at all, as the <DIV> is floated, thus you end up with the margin visually appearing on the <P> itself. You could use the DOM Inspector to see the areas covered by each element to see how it affects the position/margins of each element.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: