HTML and CSS Reference
In-Depth Information
<p id="p2">
Then it got down off the mushroom, and crawled away in the
grass, merely remarking as it went,
</p>
<p id="p3">
"One side will make you grow taller, and the other side will
make you grow shorter."
</p>
</body>
</html>
Figure 3.13: An element with different amounts of margin and padding
Notice that there are a few pixels of space between the irst paragraph,
which has 0 margins, and the edges of the browser's window. Where does this
space come from? A bit of experimentation shows that this space is the
body
element's margin! his is a bit illogical. You might expect the
body
element
to have some amount of padding so that content doesn't mash up against the
window's edges, but it should not need any margin to separate itself from
other content elements, because there are none. he body element does, in fact,
have a parent element, the
html
element, that can be given margins, padding,
borders, and background that will be recognized by most browsers. However,
how browsers should behave at the extreme margins is not well deined. Web
developers should avoid assigning any styles to the
html
element.
he
body
element's default margin amount may be due to historical reasons,
but it does have a consequence. Unlike other HTML elements, any background
color or image assigned to the body element is extended to the edges of the