understanding background-color property-VBForums
Results 1 to 2 of 2

Thread: understanding background-color property

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    154

    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.

  2. #2
    Moderator
    Join Date
    Jan 2005
    Location
    Sydney
    Posts
    13,630

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.