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 trialDimitris Karatsoulas
5,788 PointsWhy the change of margin-top property applies both on name and main-nav.
- On the 2:05 mark of the video the margin-top property of .name is changed to 50px (line 113 of CSS code), this doesn't only apply on .name but also on .main-nav. They both seem to have the same margin from the top. Why does that happen? Since they are different elements shouldn't they also have different margins?
1 Answer
issa Mohamed
7,373 PointsI can only think of it as because .main-nav and .name are both displayed as inline-block meaning inline-block elements are effectively treated as block. Block-level elements respect both horizontal and vertical margins once margin-top is applied to .name that margin spans across the full width of the block taking any inline elements like .main-nav down 50px. As .main-nav is on the same line as .name
Dimitris Karatsoulas
5,788 PointsDimitris Karatsoulas
5,788 PointsThank you for your response, this does explain that behaviour.