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 trialRavi Challa
7,036 PointsBest Practice to define Padding unit for Text in CSS
Hi
I would like to know whats the best practice to define Margins and padding for text (p, h1, h2, etc.) in terms of units like px, em or %.
Thank you challa.ravi
1 Answer
Aakash Srivastava
5,415 PointsHey Ravi Challa , today responsiveness matters .
There is only only one unit that is responsive i,e % . Now , most of the time you should use % as padding or margin , which will automatically adjust as per viewport width .
Now , in some places or occasions, may be you don't need responsive padding and margin and you don't want to change those padding no matter what the viewport width is , then you can use em , rem or px unit there . But , these cases are very rare .
Percentage is the ideal unit to use on responsive layouts.
So , go with percentages
Thanks :)
Ravi Challa
7,036 PointsRavi Challa
7,036 PointsThank you Sunny Srivastava for the inputs