W3C home > Mailing lists > Public > www-style@w3.org > July 2003

Re: Center DIV

From: David Woolley <david@djwhome.demon.co.uk>
Date: Thu, 3 Jul 2003 22:11:05 +0100 (BST)
Message-Id: <200307032111.h63LB5g09974@djwhome.demon.co.uk>
To: www-style@w3.org

> Hi, this is my first post on this list. Does anybody know 
> an efficient way to place a <div> on the center of the 
> page? I've tried everything. I read an article over @ 

This off topic (how to) question keeps coming up on this (and even more
off topic) the HTML list.  It does represent a strong market pressure, 
although one that I feel is based on a failure to understand the

It seems to imply proposals similar to these:

1) CSS should have some macro properties that do things more like
   the CENTER element in GUI HTML, rather than having to specify in
   terms of lower level operations.

2) CSS should have a mechanism that allows material of unknown vertical 
   extent to be centered in the viewport.

3) W3C should publish documents to compete against the popular book shop
   books and information on the grapevine that advise misuses of the 
   standards where the standards have techniques that can be used.

Number (1) has been extensively discussed in recent weeks, and, except to
say that I'm happy with the current position on this, myself, I won't 
discuss it further.

It is my belief that the restriction in (2) exists because of the nature
of the medium, and, in particular that incremental display is considered
the norm (even though many layout tables, often unnecessarily, frustrate
it).  Vertically centering material of unknown height requires a display 
fixup after the height becomes definite, or, arguably worse, by allowing
the text to creep up as the block is rendered.

Note that it is also undesirable to specify both an absolute height and
absolute width, or even ones relative to the font at the start of the
block, as the user and browser are allowed to override font sizes etc.
(I now do it as a matter of course because of the over use of below
default size fonts).  That can result in overflow situations, which,
in the case of anything except the direct and only child of the body 
element, might better be handled by ignoring the height constraint and
overflowing the whole page, not just the centred element.

The only time that fixed height centring seems to be allowed is when 
absolute or fixed positioning is used; that itself is vulnerable to
invalid assumptions about the size of cotents, so the damage is
already done.

The amount of mis-information, from the grapevine, offered here as off 
topic replies, indicates that there might be a role for the W3C to 
publish a CSS cookbook.  However, it will distract effort from other
areas, force too much of a concentration on misuse as a page layout
language and they will still be constrained not to describe hacks, which
may the only way of satisfying wants.  Book publishers have the luxury
of being able to cater to people's wants, as do browser developers.
Received on Thursday, 3 July 2003 17:13:42 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:08 UTC