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 trial

CSS

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.