W3C home > Mailing lists > Public > www-style@w3.org > October 2001

Re: How is it possible to devise such a feeble system?

From: Vadim Plessky <lucy-ples@mtu-net.ru>
Date: Thu, 25 Oct 2001 02:16:01 +0000
Message-Id: <200110242210.f9OMAqH14392@post.cnt.ru>
To: Jesse McCarthy <mccarthy36@earthlink.net>, www-style@w3.org
On Wednesday 24 October 2001 15:58, Jesse McCarthy wrote:
|   John-Paul Walton <jWalton@NSideas.com> wrote on 10/24/01 12:01:34 PM:
|   >I think the question being asked is why can't CSS be used to
|   > horizontally and vertically center a DIV (or any element) within
|   > another DIV.
|   >
|   >something I've been wondering about as well.
|   Indeed, that is the question.  Sounds like a pretty simple concept,
| doesn't it?

Indeed :-)
|   Andrew McFarland <andrew.mcfarland@unite.net> wrote on 10/24/01 11:34:02 
|   >At 10:00 24/10/2001 -0400, Jesse McCarthy wrote:
|   >>Using CSS how can I center the inner DIV
|   >>or really the text within the inner DIV horizontally and vertically?
|   >
|   >I'm pretty certain you can't.
|  ...
|   >What you are wanting to do is center the text vertically in the middle
|   > of the screen (or window). I don't think CSS `knows' what size the
|   > screen (or window) is. Setting the height to 100% is 100% of the height
|   > of the parent element, not the screen (or window).
|   CSS doesn't "know" anything, it is instructing the user agent.  And the
| user agent knows the resolutuion of the screen and the dimensions of the
| viewport. In an HTML document the initial containing block is represented
| by th HTML element.  If no dimensions are defined by the author for HTML,
| the width will be provided by the user agent = all of the available space
| within the viewport (browser window).  In practice, browsers do the same
| thing with the height, not to mention that, despite what the CSS 2 spec

Correct. An web authors applky JavaScript like 
w=document.body.width, h = document.body.height
(a little bit different for MS IE, but should work in Mozilla)
than divide it, than calculate new width/height/left/right position for 
element/block, and re-position it.

Ugly, isn't it?
And of course, this will not work if visitor disabled JavaScript, for 
security reasons.
| says, the browsers (at least the ones I have available for testing: IE 5, N
| 6.1 / PC / Win 98) ignore any width and height settings for HTML and use
| the entire width and height of the viewport no matter what.  If no
| dimensions are provided for BODY, it's width will be the same as HTML, it's
| parent element.  So if a DIV is placed directly within BODY in that
| situation, with it's width set to 100%, it's width will be the same as
| body, which will be the same as the viewport.
|   Let's establish for purposes of this discussion that we are talking about
| the rules stated in the CSS 2 spec, insofar as they are consistent, and not
| browser's behavior insofar as it fails to adhere to those rules.
|   What I want to know is, why is there not a (extremely simple) way for me
| to horizontally and vertically center the text, contained within the inner
| DIV, 'whole2'?

1) Because people writing CSS specs forgot to include it :-)
2) because we (you and me) were not here when CSS2 specification was in 
developemnt ;-))

IMO, it needs a fix. Let's get CSS 2.1 with this thing fixed in hands! 

Vadim Plessky
http://kde2.newmail.ru  (English)
33 Window Decorations and 6 Widget Styles for KDE
KDE mini-Themes
Received on Wednesday, 24 October 2001 18:11:30 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:59 UTC