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 trialJacob Miranda
19,080 PointsLayout: Float vs Display: Inline-block ?
I constantly see Float: Left/Right used for laying out sections of a webpage, but I have recently switched over to using the property/value pair of Display: Inline-block. Through my experience, I have found it to work better and is a lot less stressful when getting it to work properly. I also don't have to worry about clearfixes and any other headaches of forgetting to add something.
The one thing to keep in mind with displaying an element with inline-block is that you must have the closing tag and opening of the next element side-by-side.
<div>Hello world!</div><div>Hello other world!</div> A space character will be rendered as a few pixels and may mess up your layout a bit.
If anyone has an opinion of using one versus the other, please discuss!
1 Answer
Jeff Lemay
14,268 PointsUsing inline-block is used more now that box-sizing:border-box is available in more browsers.