473,769 Members | 3,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collapsing margins: A design fault?

<div style="backgrou nd-color: blue; width: 500px; height: 300px">
<div style="backgrou nd-color: red; margin-top: 100px; margin-left: 100px; width:
300px; height: 100px">
</div>
</div>

Where will the red box be positioned? Even experienced web developers often
expect it to be in the middle of the blue box, but instead (on
standards-compliant browsers) the blue box is lowered to line up its top edge
with that of the red box. This is because of collapsing margins
(http://www.w3.org/TR/CSS21/box.html#...sing-margins); the top margins of
both boxes are adjacent, so the larger margin (100px) is applied to both.

I humbly propose that this is a design fault. Collapsing margins only seem to
make sense when top and bottom margins are adjacent; in what proportion of cases
to designers want the top margins of nested blocks to collapse?

For those who wish to view nested blocks in full technicolour, I've put up a
sample at http://www.accursoft.co.uk/test.xhtml .
Sep 2 '05 #1
5 1894
Borris <no**@none.co m> wrote:
<div style="backgrou nd-color: blue; width: 500px; height: 300px">
<div style="backgrou nd-color: red; margin-top: 100px; margin-left: 100px; width:
300px; height: 100px">
</div>
</div>

Where will the red box be positioned? Even experienced web developers often
expect it to be in the middle of the blue box, but instead (on
standards-compliant browsers) the blue box is lowered to line up its top edge
with that of the red box. This is because of collapsing margins
(http://www.w3.org/TR/CSS21/box.html#...sing-margins); the top margins of
both boxes are adjacent, so the larger margin (100px) is applied to both.

I humbly propose that this is a design fault. Collapsing margins only seem to
make sense when top and bottom margins are adjacent;
The problem is that it is the right behaviour if you meticulously
analyze the specs, whether the effect was foreseen when the spec rules
were established I do not know, but changing the spec rules
retrospectively because some rule has an unforeseen effect doesn't
strike me as viable.
in what proportion of cases
to designers want the top margins of nested blocks to collapse?


Probably never, it's just another example where the specs fail to do
what people expect, CSS in general suffers from this. I've long been of
the opinion that CSS has failed in a fundamental way: it's far to
difficult to use for the people who are meant to be using it, i.e.
designers and private/amateur web authors.

The problem could have been mitigated if early on there had been good
quality visual authoring software that would have taken care of the
technical details. Problems like the above, combined with (arguably the
resulting) browser non spec compliant rendering have significantly
contributed to preventing that from happening. Designers are therefore
often still very weary of CSS because it requires them to do something
that they are often genetically ill equipped to do: get technical.

The ludicrous situation is that the techies who *are* equipped to handle
CSS and it's idiosyncratic rules are the people who typically don't have
a clue when it comes to design and styling. (I count myself amongst
these)

Unfortunately we seem to be stuck with CSS and it's fundamental
failures. Like with the errors that were made with HTML, some mistakes
are nigh impossible to correct once they have been made. Mind you, the
wrong people continue to be in charge of CSS (the techies), so the view
that CSS is fundamentally flawed is not a popular one, even if it were
possible to re-engineer the language it probably wouldn't happen.

--
Spartanicus
Sep 2 '05 #2
Thank you for your helpful reply. Is there a list around of other CSS gotchas?
I'm new to CSS design, and it would save a lot of time to know them in advance.

Spartanicus wrote:
Unfortunately we seem to be stuck with CSS and it's fundamental
failures. Like with the errors that were made with HTML, some mistakes
are nigh impossible to correct once they have been made. Mind you, the
wrong people continue to be in charge of CSS (the techies), so the view
that CSS is fundamentally flawed is not a popular one, even if it were
possible to re-engineer the language it probably wouldn't happen.

Sep 4 '05 #3
The posting convention in this group is snipping the relevant quotes
down the minimum and interleave the replies beneath it.

Borris <no**@none.co m> wrote:
Thank you for your helpful reply. Is there a list around of other CSS gotchas?
I'm new to CSS design, and it would save a lot of time to know them in advance.


Depends what you mean by "gotchas". There are sites that catalogue
browser CSS bugs and workarounds if available. I roll my own hacks and
don't use these sites, so you'll have to Google for them.

As for CSS doing unexpected things, I'm not aware of a list.

--
Spartanicus
Sep 4 '05 #4
On Sun, 04 Sep 2005 13:01:52 +0100, Borris wrote:
Thank you for your helpful reply. Is there a list around of other CSS gotchas?
I'm new to CSS design, and it would save a lot of time to know them in advance.

Spartanicus wrote:


Take a look at http://www.positioniseverything.net/ it's a start.
Sep 4 '05 #5
> Take a look at http://www.positioniseverything.net/ it's a start.

Thank you, it looks very interesting.
Sep 5 '05 #6

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

Similar topics

0
1654
by: Spartanicus | last post by:
I've been caught out by what I thought was an Opera 7.5p1 issue: http://www.spartanicus.utvinternet.ie/test/opera7.5p1_css_background_image_issue.htm but as was pointed out to me this is actually a fault in my code which is exposed by the improved CSS standards support in v7.5p1. The top margin on the <h1> collapses with the zero margin on the <body> element to form a single margin equal to the margin specified on the <h1>.
2
2423
by: Stanimir Stamenkov | last post by:
I'm trying to clear some sizing issues relative to the initial containing block and the root document element. The sample document I'm trying with: http://stanio.info/viewport_fill.html Basically, for some tests I want to specify the height of an example DIV element inside the BODY using percentages of the viewport height. For this to work the BODY container should fill the viewport height where I'm using:
1
1738
by: yb | last post by:
Hi, I'm looking for clarification of css 2.1 specification in section 8.3.1 "Collapsing Margins" The 6th bullet reads "If the top and bottom margins of a box are adjoining ..." I won't paste the whole point here, its too long. But, from this first line does this mean that the element has empty
7
21746
by: steve | last post by:
Hi All I have created rdlc files and when I load them into Report Viewer at run time they appear OK If I click on 'Print layout' button on Report Viewer the view again appears acceptable If I click on 'Page setup' button the margins left & right are not what I set on the rdlc file at design time (1.5cm) they are 5.9mm
1
5958
by: Jeremy | last post by:
Let's say I have some block elements that self-organize by floating to the left, so if no more blocks can fit in a row they begin on the next row (see crummy ASCII art at end of message). I could define the CSS for one of the floating elements as such: ..floater { float: left; width: 48%;
12
2798
by: cmk128 | last post by:
Hi I am an os developer, i am developing a gui library. I found that java swing is the most easiest to use gui library , am i correct? I am trying to port swing to c++, is there any thing i should be careful? thanks from Peter (cmk128@hotmail.com)
5
1963
by: SlowArrow | last post by:
Here collapsing seems to work differently in vb.net 2005 from that I use to see in vb.net 2003: Using the collapsing in vb.net 2003 shows the whole interface of the methods, subroutines, functions, etc, while in vb.net 2005 those parts after the name (arguments, etc) are missing. Is there an option to show them as well, or this is the only working method of the collapsing? What amazed me that the collapsing in the vC.net 2005 shows the...
1
2145
by: pdm | last post by:
I think a well known access problem. If you customize the default margins of a report they doesn't remain fixed. The margins jumps back to the default margins for reports (which are sometimes to width) when you open it again or change something on the desing of the report. thanks for a help to fix this awkward problem or margin.
4
16740
by: =?Utf-8?B?SGVyYg==?= | last post by:
Using the WebForms.ReportViewer when I export to PDF, the margins of the report are too large. How can I change the margins of my report to make better use of the printed page space?
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.