-
Dec 12th, 2011, 02:16 AM
#1
Thread Starter
Addicted Member
understanding background-color property
With Ref
http://www.w3schools.com/cssref/pr_background-color.asp
The background of an element is the total size of the element, including padding and border (but not the margin).
But when I set top margin for body tag then its margin is also colored black. While if I move that style to p tag then it works for only p tag background and margin is not colored black.
HTML Code:
<body style="margin-top:200px; background-color: black; color:white; border: 1px solid red;">
<h1>Test</h1>
<p>Hello World!!</p>
</body>
What's I am understanding wrong?
Last edited by Peon; Dec 12th, 2011 at 02:23 AM.
-
Dec 12th, 2011, 08:56 AM
#2
Re: understanding background-color property
It's magic: the body background becomes the viewport background, unless you define them separately:
HTML Code:
<!doctype html>
<html style="background: white">
<body style="margin-top:200px; background-color: black; color:white; border: 1px solid red;">
<h1>Test</h1>
<p>Hello World!!</p>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|