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 trialDavide Pugliese
4,091 PointsConsistency in a fluid layout
In order to reinforce best practices, as a matter of consistency, wouldn't it be fair to set the margins, etc. even for a elements as percentages instead of as px?
1 Answer
Nick Beukema
6,359 PointsThis all depends on how you'd prefer your layout to be.
Using a percentage based margin, or a margin:auto setting, has been the go-to for a while, although using a fixed margin base is now easily achieved with the flex property.
You're right though, to create a fluid layout you're going to want a percentage based margin for your major layout elements.
I would not say, as a part of best practices, that I would put percentage based margins on my [a] tags though. I think that's more of my personal preference. With elements like that, I like to know their size (total size including padding/margin) and also maintain the correct spacing between elements with different screen sizes.
This is something you could do, but as the screen size gets smaller, you wont find a percent margin/padding that will work for both a screen 1200px+ wide and one thats 400px wide.
Hope that answers your question!