Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Put Div Tag at top of page without space

Tags:

css

I want to put a div tag with id "wrapper" at top of page, but the problem is that there is a white space between the div tag "wrapper is yellow color"
and the top of page.

My question is how can I remove the white space between the div tag and the top of page?

Here is my code

    <!DOCTYPE html>
    <html>
     <head>
     <style type='text/css'>
     body {
    	margin: 0;
    	padding:0;
     }	 
    	
     #wrapper {
    	width:1000px;
    	text-align:center;
    	margin-right:auto;
    	margin-left:auto;
    	margin-top:0px;
    	background-color: yellow;
    	padding:0px;
     }
     </style>
     </head>

     <body>
      <div id="wrapper">
       Testing
      </div>
     </body>
    </html>
like image 839
Ramy Nabiel Avatar asked Oct 12 '13 10:10

Ramy Nabiel


2 Answers

Try this in the css code:

{
 position:absolute;
 top:0px;
}

You can use the right or left to make a space between the div and the corner

like image 75
AME Avatar answered Sep 27 '22 21:09

AME


The problem is: https://stackoverflow.com/a/5910170/2670516

Try replace all your code by:

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <style type="text/css">
    body {
      margin: 0;
      padding:0;
    }    
    #wrapper {
      width:1000px;
      text-align:center;
      margin-right:auto;
      margin-left:auto;
      margin-top:0px;
      background-color: yellow;
      padding:0px;
    }
  </style>
</head>
<body>
<div id="wrapper">
  Testing
</div>
</body>
</html>
like image 30
André Augusto Costa Santos Avatar answered Sep 27 '22 20:09

André Augusto Costa Santos