Forum Moderators: not2easy
body {
background: #EDEDED;
}
it is quite common to set values for the "html element". ;)
Here is an example of it's use...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS usage of HTML element</title>
<style>
html, body {
height:100%;
margin:0;
background-color:#f93;
}
#container {
width:960px;
height:100%;
margin:auto;
background-color:#fff;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
</html>
Remove "html," from the CSS and see what happens. :)
It's non-standard
Inheritance starts at the oldest ancestor, i.e. the top-level element. In HTML, this is is the 'HTML' element (although many HTML authors omit this tag). In order to set a "default" style property, one should use 'HTML' as selector: HTML { color: dark-blue }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
html{background:blue}
body{background:red}
</style>
</head>
<body>
<p>test</p>
</body>
</html>
For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. For documents whose root element is an HTML "HTML" element or an XHTML "html" element that has computed values of 'transparent' for 'background-color' and 'none' for 'background-image', user agents must instead use the computed value of the background properties from that element's first HTML "BODY" element or XHTML "body" element child when painting backgrounds for the canvas, and must not paint a background for that child element. Such backgrounds must also be anchored at the same point as they would be if they were painted only for the root element
But the whole document including the margins will be #CCC, just as if you'd said {padding} instead.
html{background:red}
body {margin: 10%; background-color: #CCC;}