In article <
MPG.298d06f38...@news.demon.co.uk>,
Philip Herlihy <
bounc...@you.com> wrote:
...
>
> I'm pretty likely to be corrected, but I understand that you simply
> can't set height to be 100%, and if you could, you'd be setting it to
> 100% of the container's *width*. Given that a web page can have
> arbitrary height, I'm not even sure what 100% height would mean.
> Containers (as I understand it) take their height from what they are
> asked to contain, unless you set a specific height (e.g in px).
Yes, containers can take their height from the contents and they can
instead be given a height. Some containers have zero height in spite
of having very substantial content, as when their children are floats
and therefore 'out of the flow'.
But you can set height to be 100% to most if not all elements and it
is done often enough to good effect. It means that the element
(including its baggage of borders, paddings, margins) is as high as
the content height of its parent.
Where people want to make their elements stretch the full height of
their viewports, they need to tell *all* the relevant hierarchy of
elements what heights they should be. No good giving just the third
div below a percentage height for this. What is needed is
html, body, div {height: 100%;}
<html>
<body>
<div>
<div>
<div>
I want to stretch the full height of the viewport
</div>
</div>
</div>
</body>
</html>
What could the HTML element be a percentage of? Good question, even if
I say so myself. There is a little obscurity or slightly uncertain bit
of the specs on containing blocks but it turns out that the HTML
element is not quite the god it thinks it is. I stopped being so
religiously in awe of it when I found out that it could be dependent
(a *dependent* god? c'mon!). It can be made to climb on a little
platform at the crack of a whip.
It will be 100% of the *the viewport*.
And the viewport is under the control of the user's hardware, medium,
his or her choices etc. A bit like God seems to be when you look
around the world and read a bit of history.
If you are not convinced that the HTML is basically just a circus
animal like the rest of the human gods, try this in Safari or Firefox:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"
http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<title>At the crack of a whip</title>
<style type="text/css">
html {border: 1px dotted; height: 50%; width: 50%; margin: auto;}
</style>
</head>
<body>
</body>
</html>
--
dorayme