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

HTML How to Make a Website Styling Web Pages and Navigation Build Navigation with Unordered Lists

Keith Grimes
PLUS
Keith Grimes
Courses Plus Student 2,356 Points

Practical difference between float and max-width?

Could someone explain to me the practical difference between using float or using max-width to center an object, either text or image?

I guess when I look at the heading text (Nick Petit | Designer) my thought would be to use max-width and align-text: center. It never occurred to me to use float.

What are you thinking that leads you to somehow know that float is the way to go here, rather than the way I was thinking?

Thank you. Keith

1 Answer

Hey Keith-

The way I worked through it in my head when going through the early courses was that max-width applied to the container that contained various elements. Float applies to those elements within the container. You can also set the max-width of the various children/elements of the parent container, but I've always thought of float as solely being used to move elements around within the container. Hope this helps

And just about the time you get your head wrapped around that you will have to forget it to get your head wrapped around flex-box!