Web Analytics Made Easy -
StatCounter CSS Divs - CodingForum

Announcement

Collapse
No announcement yet.

CSS Divs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CSS Divs

    So the problem is that my divs in CSS don't fully extend to the edges of the screen. I set the background color of the entire page as red in my style.css file, like so:

    Code:
    body
    {
    	background:red;
    }
    Then I create a div named "container" and set the background as blue, like so:

    Code:
    #container
    {
    	text-align:center;
    	width:100%;
    	background:blue;
    }
    My html file consists of this:

    Code:
    <html>
    	<head>
    		<title>
    			Website Title
    		</title>
    		<link rel="stylesheet" href="style.css" type="text/css" media="all">
    	</head>
    	<body>
    		<div id = "container">
    		<p>hello</p>
    		</div>
    	</body>
    </html>
    The red background extends to the edges of the screen and has no problems. The blue background appears to have some kind of invisible margin between the top and the sides of the screen where the area is still red.

    Here is a screenshot of what's happening:



    How can I make the div extend and reach the top and sides of the page?

  • #2
    Try this at the start of your style sheet.

    Code:
    * {
    	padding: 0;
    	margin: 0;
    	}
    shockup.com

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎