Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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/).