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

set margin 0 on body did not work

I try to set a margin to 0 on my css, but there is still space on the top, it only set the left and right margin but not on the top. I try to make it the same as the video, but why did I get different result ?

thank you

I tried to use ( * ) universal selector, and it works. But when I tried to use it on my body it didnt.

2 Answers

I'm not sure about which video your talking about. But are you sure it's not actually padding that you are seeing?

Its video type selector on CSS Basic. On the body css selector he set the margin to 0, which makes the white spaces disappear. But when I tried making my own page, I set the margin to 0 on body selector, but there is still white space on the top margin.

Could you post your code?

/*base style */

body { margin: 0; } body { font-family: Helvetica, Arial, sans-serif; }

h1 { color: white; font-size: 6.2em; text-transform: uppercase; margin-top: 80px; text-align: center; } ul { text-align: right; margin-right: 100px; } li { display: inline; text-transform: uppercase; color: white; margin-left: 30px; font-size: 1em; }

<!DOCTYPE html> <html> <head> <title>fadhilfath</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <!-- body html --> <body> <header id="top" class="main-header"> <ul> <a href="#"><li>About Me</li></a> <a href="#"><li>My Work</li></a> <a href="#"><li>My Blog</li></a> <a href="#"><li>Contact Me</li></a> </ul> <h1>fadhilfath</h1> <a href="#"><span class="mywork">my work</span></a> </header> <!-- about me content --> <div class="aboutme"> <h2>About Me</h2> <p>fadfjadfajdnkfad </p> </div> <!-- the end of about me --> <footer class="main-footer"> <p>Copyright Fadhil suhendi</p> <a href="#top">Back to the top</a> </footer>

</body>

</html>