Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

White Space in Header

White spacing has appeared in my header of my webpage and I'm not sure why. I looked through all the questions relating to this problem but I still haven't been able to solve my issue.

When I was going through the coding to fix this problem originally, I didn't have a problem. The white spacing around the header disappeared and all was well. Then, the other day I edited my HTML and didn't touch my CSS and the white spacing appeared; except is wasn't only on the top now but on the right and left side as well. I'm really confused because there only thing I did to my HTLM was delete a picture in my gallery... for the life of me I can't figure out this problem and I would really appreciate any help you could throw my way.

Thanks!

Here is my CSS

/*****************
GENERAL 
*****************/

body {
  font-family: 'Cabin', sans-serif;
}

#wrapper {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 5%;
}

a {
  text-decoration: none;
}

img {
  max-width: 100%;
}

h3 {
  margin: 0 0 1em 0;
}




/*****************
HEADING 
*****************/

header {
  float: left;
  margin: 0 0 30px 0;
  padding: 5px 0 0 0;
  width: 100%;
}

#logo {
  text-align: center;
  margin: 0;
}

h1 {
  font-family: 'Lobster Two', sans-serif;
  margin: 15px 0;
  font-size: 1.75em;
  font-weight: normal;
  line-height: 0.8em;
}

h2 {
  font-size: 0.7em;
  margin: -5px 0 0;
  font-weight: normal;
}



/*****************
NAVIGATION
*****************/

nav {
  text-align: center;
  padding: 10px 0;
  margin: 20px 0 0;
}

nav ul {
  list-style: none;
  margin: 0 10px;
  padding: 0;
}

nav li {
  display: inline-block;
}

nav a {
  font-weight: 800;
  padding: 15px 10px;
}



/*****************
Footer 
*****************/

footer {
  font-size: 0.75em;
  text-align: center;
  clear: both;
  padding-top: 50px;
  color: #F9BCC9;
}

.social-icon {
  width: 20px;
  height: 20px;
  margin: 0 5px;
}



/*****************
Page: Portfolio  
*****************/

#gallery {
  margin: 0;
  padding: 0;
  list-style: none; 
}

#gallery li {
  float: left;
  width: 45%;
  margin: 2.5%;
  background-color: #f5f5f5;
  color: #bdc3c7;
}

#gallery li a p {
  margin: 0;
  padding: 5%;
  font-size: 0.75em;
  color: #bdc3c7;
}

/*****************
Page: About
*****************/

.profile-photo {
  display: block;
  max-width: 150px;
  margin: 0 auto 30px;
  border-radius: 100%;
}

.contact-info a {
  display: block;
  min-height: 20px;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  padding: 0 0 0 30px;
  margin: 0 0 10px;
}

.contact-info li.phone a {
  background-image: url('../img/phone.png');
}

.contact-info li.mail a {
  background-image: url('../img/mail.png');
}
/*****************
Page: Contact
*****************/

.contact-info {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9em;
}


/*****************
COLORS
*****************/

/* site body */
body {
  background-color: #fff;
  color: #bdc3c7;
}

/* pink header */
header {
  background: #FA97AE;
  border-color: #F9BCC9;
}

/* nav background on mobile */
nav {
  background: #F9BCC9;
}

/* logo text */
h1, h2 {
  color: #fff;
}

/* links */
a {
  color: #F9BCC9; 
}

/* nav link */
nav a, nav a:visited { 
  color: #fff;
}

/* selected nav link */
nav a.selected, nav a:hover{
color: #E84C82 ;
}

& HTML

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title> MA | Web Design </title>
    <link rel="stylesheet" href="css/normalize.css">
  <link href='http://fonts.googleapis.com/css?family=Cabin:400,700,400italic,700italic%7CLobster+Two:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/responsive.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <header>
       <a href="index.html" id="logo">
        <h1>MA</h1>
        <h2>Web Design/h2>
       </a>
      <nav>
        <ul>
          <li><a href="index.html" class="selected"> Portfolio</a></li>
          <li><a href="about.html">About</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </nav>
    </header>
    <div id="wrapper">
    <section>
        <ul id="gallery">
          <li>
            <a href="img/IMG_2847.JPG">
              <img src="img/IMG_2847.JPG" alt="">
              <p>1</p>
            </a>
          </li>
          <li>
            <a href="img/IMG_9583.JPG">
              <img src="img/IMG_9583.JPG" alt="">
              <p>2</p>
            </a>
          </li>
          <li>
            <a href="img/File0493.JPG">
              <img src="img/File0493.JPG" alt="">
              <p>3</p>
            </a>
          </li>
          <li>
            <a href="img/IMG_9370.JPG">
              <img src="img/IMG_9370.JPG" alt="">
              <p>4</p>
            </a>
          </li>
          <li>
            <a href="img/IMG_9555.JPG">
              <img src="img/IMG_9555.JPG" alt="">
              <p>5</p>
            </a>
          </li>
        </ul>
      </section>
      <footer>
        <a href="http://instagram.com/"><img src="img/instagram+button.png" alt="Instagram Logo" class="social-icon"></a>   
        <p>&copy; 2014 MA</p>
      </footer>
    </div>
  </body>
</html>

3 Answers

Hi Marie!

The white space you are seeing around your header is caused by the browser. Most browsers have some default styling which will effect your webpage.

In order to remove the white spacing around your header try adding the following to your css:

body{ padding: 0; margin: 0; }

I hope this solves your issue :)

Hi there adamdonatello,

After having the same problem your post has solved my issue, thanks dude!

Josh

Hi Josh,

That's great! I'm glad I could be of some assistance :)

Adding margin: 0; should resolve your issue, also your h2 tag isnt closed.

Hi adamdonatello and imuya,

Thanks for giving me some great advice! I am happy to report my problem has been solved!

Yippie :D