Because you were missing the DOCTYPE — which really should have been there to begin with — your page was being rendered in quirks mode. In quirks mode, browsers are known to stretch the height of body
to 100% of the height of the viewport. In standards mode, which is triggered by having an appropriate DOCTYPE, body
behaves like a regular block-level element, being only as tall as its contents by default. In your case, this results in body
's background color not being visible.
There's nothing inherently wrong with your CSS, which is why it validates, but if you want body
to stretch to the height of the viewport in standards mode, you should add the following height properties to html
and body
respectively:
html {
height: 100%;
}
body {
min-height: 100%;
}