.myDiv
{
background-image: url(urltomyimgheader);
height:100px;
margin: auto;
position:relative;
top:-10px;
width:600px;
}
This is a simple div tag used to display the logo…
I have made the top -10px to make it touch the top of the browser where unless there is a gap between the logo and the page.
However i feel bad about using the -10px to position the div 🙁 Is there a better and cross browser compatible solution?
@Tatu Ulmanen is right that this is a browser default issue. You shouldn’t have to add negative margins, you simply need to set the default CSS attribute of the body/html tags.
Just to be safe you should be using a CSS reset to get rid of Browser styling defaults anyways. Here’s the code you can use to solve your problem. Below that is a nice CSS Reset you can add to the top of all your CSS stylesheets from here on out.
CSS Reset:
/* Reset */