Quick tip: Full-height (height 100%) page in XHTML strict 1.0

This may be counter-intuitive (like most of the XHTML spec and how it’s implemented), but everything, even the element is treated like an element, and therefore makes it a pain in the arse to make anything height: 100%.

Long story short, if you have a div on your page, and you want it to fill the full vertical height of the screen, the portable way to do that is to do the following:

HTML:

<html>
<head>
<title>Full height</title>
</head>
<body>
<div id=’pageWrapper’>
Those-who-can, do; those-who-can’t write a standard then don’t support it so that those-who-can have to waste their time hacking around these mistakes. This way, those-who-can’t don’t look as bad next to those-who-can’s now more mundane accomplishments.
</div>
</body>
</html>

CSS:

html{
height:100%; /* means 100% of the client window */
}
body{
height: 100%; /* means 100% of the ‘html’ element */
}
#pageWrapper{
height: 100%; /* means 100% of the ‘body’ element… fuckssake*/
display:table;
}

There you have it. You might want to remove my vulgar op-ed comment before putting that in production code. Enjoi.

Add comment December 9th, 2007

“That’s it guys, I’m out.” – Token

Add comment December 15th, 2006

I’m going to vomit. W3C has a page rank of 10.

Add comment December 15th, 2006

OMG! check out my movie!!1!

Add comment August 19th, 2006

New Blogging System!

Add comment June 14th, 2006

How to make a valid page…

Add comment April 12th, 2006

omfgcenter!

Add comment March 23rd, 2006

Welcome to iHateCSS.org

Add comment March 23rd, 2006


Categories

Links

Feeds