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

HTML

nicholas maddren
nicholas maddren
12,793 Points

small margin between div's even when margin is set to 0?

I am doing a little project and just wondering why these div's are behaving in this way? If you look at:

http://www.thornabytyres.com you will notice I have made a red box that is made from two div's the first div is for the red area and the second div for the white, any idea why there is a very faint 1 pixel line between them and how I can remove them? Even with margin set to 0 in my CSS it wont go, I could nudge the second div up but I'd like to know why it is doing this? Thanks!

2 Answers

Stephen O'Connor
Stephen O'Connor
22,291 Points

It's because their display is set to inline-block. Inline block elements have a space if there is white space in your HTML for some strange reason ... check here for an explanation (http://css-tricks.com/fighting-the-space-between-inline-block-elements/).