473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

2-column layout and top margin of floated column

Hello.

I seek confirmation for the reasons behind a margin-related behavior I
have observed. I have set up a simple test page [1] to illustrate the
issue. The page shows a very simple 2-column layout, where columns are
contained in /div/ elements.

The first column is floated left and the second one is offset by a left
margin. You should be able to notice that the contents of the first
column are lower than those of the second one. Is that an instance of
the behavior defined in section 8.3.1 [2] of the CSS 2.1 standard?
Namely, "Vertical margins between a floated box and any other box do not
collapse (not even between a float and its in-flow children)."

Bringing that definition onto the case in hand, would it be correct to
conclude that the bottom margin of the heading and the top margin of the
first paragraph of the first column are not collapsing and, therefore,
the resulting total margin is bigger than that of the second column?

[1] http://zunino.eti.br/css/tests/2-column.html
[2] http://www.w3.org/TR/CSS21/box.html#collapsing-margins

Thank you,

--
Ney André de Mello Zunino
Apr 19 '07 #1
3 3190
Ney André de Mello Zunino wrote:
The first column is floated left and the second one is offset by a left
margin. You should be able to notice that the contents of the first
column are lower than those of the second one. Is that an instance of
the behavior defined in section 8.3.1 [2] of the CSS 2.1 standard?
Namely, "Vertical margins between a floated box and any other box do not
collapse (not even between a float and its in-flow children)."

Bringing that definition onto the case in hand, would it be correct to
conclude that the bottom margin of the heading and the top margin of the
first paragraph of the first column are not collapsing and, therefore,
the resulting total margin is bigger than that of the second column?
And you can see why this behaviour by setting the bottom margin of the
h1 element to 0.

Louise
Apr 19 '07 #2
On 2007-04-19, Ney André de Mello Zunino <zu****@inf.ufsc.brwrote:
Hello.

I seek confirmation for the reasons behind a margin-related behavior I
have observed. I have set up a simple test page [1] to illustrate the
issue. The page shows a very simple 2-column layout, where columns are
contained in /div/ elements.

The first column is floated left and the second one is offset by a left
margin. You should be able to notice that the contents of the first
column are lower than those of the second one. Is that an instance of
the behavior defined in section 8.3.1 [2] of the CSS 2.1 standard?
Namely, "Vertical margins between a floated box and any other box do not
collapse (not even between a float and its in-flow children)."

Bringing that definition onto the case in hand, would it be correct to
conclude that the bottom margin of the heading and the top margin of the
first paragraph of the first column are not collapsing and, therefore,
the resulting total margin is bigger than that of the second column?

[1] http://zunino.eti.br/css/tests/2-column.html
[2] http://www.w3.org/TR/CSS21/box.html#collapsing-margins
Correct. In the second column, the top margin of the first <pcollapses
with the bottom margin of the <h1(even though the <pis nested inside
the <div>, which is rather surprising at first, but is what's meant to
happen-- see 8.3.1 of the CSS 2.1 spec).

If you want both columns to line up, one way to do it is to give each
div top padding of 1px. That keeps the <ptop margin and <h1bottom
margin apart so they can't collapse.
Apr 19 '07 #3
Ben C wrote:
Correct. In the second column, the top margin of the first <pcollapses
with the bottom margin of the <h1(even though the <pis nested inside
the <div>, which is rather surprising at first, but is what's meant to
happen-- see 8.3.1 of the CSS 2.1 spec).

If you want both columns to line up, one way to do it is to give each
div top padding of 1px. That keeps the <ptop margin and <h1bottom
margin apart so they can't collapse.
If you add DIV { background-color: #eee; } you can see what's and
happening and also how MSIE works contrary by collapsing the top margin
of the first P in the first DIV...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Apr 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Alfred | last post by:
I essentially have the standard two column layout, but I'm running into a quirk I'm hoping someone can help with. I have one column which is the main content (75%) of the screen and the remaining...
16
by: Dan V. | last post by:
How do you do a css 2 column layout with header and footer, with the 2nd column auto-stretching so entire page looks good for 800 x 600 resolution as min. and 1024 x 768 resolution as a max? ...
19
by: Jerry | last post by:
Hi Folks, Ok, here's my story. I was asked to create a website for the church I attend. I am a complete newbie to creating websites. So, I did the usual -- did a bunch of googling, found...
30
by: Diane Wilson | last post by:
I'm trying (once again) to figure out how to make a robust CSS layout style that can replace tables. I'd like to be able to do a basic two-column layout, with a one-column header, a two column...
3
by: Spondishy | last post by:
OK... After a previous post, I've decided that the site layout will be two columns The layout will be: 1) Page 100% wide 2) Right column will be fixed 150px, left column will use the rest...
9
by: Xavier van Unen | last post by:
Hi guys and gals, I'm working on a 2 column CSS layout (for an ordering system) in which it isn't a priori known which of the two columns will be the longest, that depends on the (script...
9
by: TristaSD | last post by:
Hi, How do I accomplish the following: In a two-column layout, the right column is 200px wide, and the left column is fluid? Thanks!
1
by: chr.aleksander | last post by:
Hey, I need a solution to two problems: #1 I use a three column layout, where the right and left columns are 150px wide and floated. The center column is not floated, with margins 150px on each...
1
Death Slaught
by: Death Slaught | last post by:
I will be showing you how to make a very simple but effective three column layout. First we will begin with the HTML, or structure, of our three column layout. <!DOCTYPE html PUBLIC...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.