W3C home > Mailing lists > Public > www-style@w3.org > January 2011

Re: margins, ems and context

From: Gérard Talbot <www-style@gtalbot.org>
Date: Tue, 25 Jan 2011 11:26:50 -0800
Message-ID: <d8979ab5457c8aac7a034a34061cd06c.squirrel@cp3.shieldhost.com>
To: "Ambrose LI" <ambrose.li@gmail.com>
Cc: "Niels Matthijs" <niels.matthijs@internetarchitects.be>, "W3C style mailing list" <www-style@w3.org>

Le Mar 25 janvier 2011 10:57, Ambrose LI a écrit :
> 2011/1/25 "Gérard Talbot" <www-style@gtalbot.org>:
>> And as pointed out by Anton Prowse, why would horizontal margins
>> dependent
>> on the font size of the containing block be useful?
>
> Why not?

One reason would be that horizontal margins do not collapse for starters.
Assuming this code:

body {margin: 0.5em;} /* == 8px since font-size is initially set to medium
by modern browsers */

h1 {margin: 1em;} /* == 32px since font-size for h1 element is by default
set to 2em in modern browsers */

(...)

<body>

 <h1>Hello world!</h1>

then, when font-size increases, the body available width area for display
"shrinks" and the heading available width area also "shrinks" to a second
degree (<h1> has larger margins, leaving less width to its content and
<h1>'s containing block's width has diminished too).

> I do it myself. This is what we will do if we are discouraged
> from using pt. I thought people on the list thought that we should do
> percentage- and em-based designs.

It depends on what you want to do exactly.

E.g.:

Increase and decrease font-size in this page:
http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/CSSColumnarLayoutThatFails1.html

What do you notice? When font-size increases, then the relative width
importance of the left column (with navigation menu) with regards to the
whole page increases (takes more horizontal space) when, maybe, the web
author only wanted the individual navigation menu items to be taller (so
that it would allow longer, bigger link texts to wrap around) but maintain
the initial width proportions (between left column versus rest of page
available width or whole page available width).

regards, Gérard
-- 
CSS 2.1 Test suite RC5 (January 11th 2011)
http://test.csswg.org/suites/css2.1/20110111/html4/toc.html

Contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/

Web authors' contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/web-authors-contributions-css21-testsuite.html
Received on Tuesday, 25 January 2011 19:27:28 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:36 GMT