Simplest of pages to demonstrate my problem:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html, body
{
height: 100%;
overflow: hidden;
}
body
{
margin: 0;
padding: 0;
}
#container
{
background: red;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
</html>
div-container correctly fills the browser window with red. Now wrap the div in a form:
<body>
<form>
<div id="container"></div>
</form>
</body>
and div-container collapses. Why? What is it about a form tag that ‘breaks’ the ‘closest ancester with height’?
formis ablockelement, block elements don’t have any height unless their content expands or they’re explicitly given a height. The closest ancestor of#containerisform, and it’s height is0, so#containers height is0.