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

General Discussion

Joseph Torres
Joseph Torres
6,282 Points

Practicing my HTML and CSS coding

As I practice to code more and more, I'm realizing that the things Im trying to grasp is when to properly use an HTML or CSS element or layouts. Just my thoughts here but how does one eventually and intuitively know when change the margin or border or when to use pixels or em's and so on... Who feels this way???

Well one thing ive learned is that using ems and percentages are handy when building responsive designs, otherwise using pixels are going to give it a fixed size. So when building websites i tend to stick for the most part with ems and percentages

1 Answer

jag
jag
18,266 Points

It all depends on what you are trying to achieve. You can come up with various solutions when creating something.

Since pixels is static it's not a good choice for responsive design; em would be the better choice. Anything that relates with typography I'll use em. Example line-height, padding, margin, font-size & letter-spacing

As for percentages I leave that to structure as the percentage is relative to where you use it and carries different value that you can confuse.