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.


Floating elements or display: inline-block?

Wich one is better for responsive layouts?

2 Answers

Josh Alling
Josh Alling
17,172 Points

Both work in responsive layouts, but they are used for different situations. If you want multiple elements to display in a horizontal line across the page (i.e. the links in a nav bar), use inline-block. This allows you to display the elements horizontally, but still retain your margins and padding. Floating an element is often used to push one element to the left or right and allow other elements to wrap around it.

Hope this helps.

Yes, helped alot! Thank you!!

If anyone has something to accent please any hint will be welcome.