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 trialShaked Gvirtsman
2,270 PointsWhy do we use "display: inline-block;"
I'm a bit confused, why do we use
display: inline-block;
2 Answers
Aakash Srivastava
5,415 PointsHey Shaked Gvirtsman ,
We can not set top and bottom margins on inline elements because inline elements flow with content on the page. You can set left and right margins/padding on an inline element but not top or bottom because it would disrupt the flow of content.
That's why Guil converted them into an inline-block so that he can apply those properties to them .
Setting an element to inline-block gives your more freedom to style them .
Jesse Dispoto
Front End Web Development Techdegree Graduate 14,538 Pointsinline-block acts as an inline element but with certain block-level element properties, such as the margin property like Gil showed in his demo.