Reputation: 111
First timer here. Could someone please tell me why there are margins around the header? How can I fix it?
jsfiddle: http://jsfiddle.net/lauriecai/39J2B/3/
header {
width: 100%;
height: 100px;
background-color: #fff;
}
Upvotes: 2
Views: 390
Reputation: 25392
There are actually two things at work here.
By default, the body has margins of around 5px(ish). Most of the answers on here have already covered that. You can fix it by setting them to 0;
body
{
margin: 0;
}
<h1>
ALSO has marginsYour header is being pushed down by the margins on your <h1>
element. Remove the top margins to fix it.
h1
{
margin-top: 0;
}
Upvotes: 2
Reputation: 11171
When posting to SO, you generally want to put your code into a
since it gives everyone the ability to easily access the code you've already written/attempted. Images are both tedious and difficult to work with and will probably deter people from helping you. I'd try to avoid them when you want to post code.
Nevertheless, the actual answer to your question:
If you want to remove all padding and margins, you should add the following CSS to your index.css
file:
html, body {
padding: 0px;
margin: 0px;
}
Upvotes: 1
Reputation: 4370
<body>
<header>
<a href="index.html">
<h1>LAURIE</h1>
<h2>DESIGNER</h2>
</a>
</header>
</body>
css
/*general*/
body{
margin: 0;
padding: 0;
}
or
*{
margin: 0;
padding: 0;
border: 0;
outline: 0;
}
also position: absolute;
Upvotes: 0