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

CSS remove top space of a webpage

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Jiliang Shentu</title> <link rel="stylesheet" href="/Users/jiliangshentu/Documents/atom/mywebpage/normalize.css"> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,800,800italic|Oswald|Poiret+One|Indie+Flower' rel='stylesheet'type='text/css'> <link rel="stylesheet" href="/Users/jiliangshentu/Documents/atom/mywebpage/main.css"> </head> <body> <header> <a href="index.html" id="header1"> <h1>Welcome, this is Jiliang Shentu.</h1> </a> <a href="index.html" id="header2"> <h2>A self-taught Web Developer</h2> </a> <nav> <ul> <li> <a href="portfolio.html">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> <p class="temp">The website is still being built now.</p> <a href="/Users/jiliangshentu/Documents/atom/mywebpage/images/numbers-01.jpg"> <img src="/Users/jiliangshentu/Documents/atom/mywebpage/images/numbers-01.jpg" alt="Order of Car battery change"> </a> <p class="temp">I am getting started loving web programming</p> </section> <footer> <a href="https://www.facebook.com/jlshisthzprc6290"><img src="/Users/jiliangshentu/Documents/atom/mywebpage/images/facebook-wrap.png"alt="facebook icon"></a> <p>Ā© 2016 Jiliang Shentu.</p> </footer> </div> </body> </html>

/*************************** General ***************************/

a { text-decoration: none; } /* remove the underline from the headers */

wrapper {

max-width: 940px; margin: auto; padding: 0 5%; } /* id selector wraaper */

img { max-width: 100%; }

/*************************** Navigation ***************************/

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

footer { text-align: right; }

/*************************** Color ***************************/

header { background-color: #6ab47b; }

body { background-color: #ffffff; } /* chenge the background color to white */

header1, #header2 {

color: #fff; } /* id selectors header1 and header2 color change */

nav a, nav a:visited { color: #fff; } /* pseudo class visited, set the links colors to green even through after visited */

section p.temp { color: #6ab47b; } /* class temp, apply the new color to it */

nav a:hover { color: #6d76a5; } /* pseudo clas hover, set the color to pink when the links are being hovered */

/*************************** Headng ***************************/

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

header1, #header2{

text-align: center; margin: 0; font-size: 0.85em; } /* id selectors header1 and header2 text centered */

h1 { font-family: 'Poiret One', sans-serif; margin: 15px 0; line-height: 0.8em; }

h2 { font-family: 'Indie Flower', sans-serif; margin: -5px 0 0; }

1 Answer

Hello Jiliang,

After sifting through your code, I found one mistake that may slightly impact your code.

margin-top: 0 0 30px 0;

To remove any white space above your header, try adding the code below to your header.

top: 0;

This will hopefully remove any white space above your header. Let us know if it works!

P.S: This is also useful for your footer. Adding bottom: 0; will push the footer down to the bottom.

Hi, Anthony,

Thanks for the advise, however, the space is still there, I am wondering if the normalize.css is causing this issue.