CSS CSS Basics Understanding Values and Units Pixel Units

Batuhan Bardak
Batuhan Bardak
3,107 Points

Should we avoid from using px ?

pixels are absolute values so I think that it is not good choice for responsive design. Depend on this, my question is should we avoid from using pixels length or in which situation should we use it ?

Thanks !

2 Answers

David Conner
STAFF
David Conner
Treehouse Guest Teacher

Relative units such as percentages or ems, rems, etc. are always better to use as they are not fixed values. Pixels can be used but you will be causing a lot more work. Take this codepen for example. http://codepen.io/davidicus/pen/LEWReB . I am able to scale these icons by changing one font-size because I have used relative units. If I had used pixels I would have to adjust each and every pixel value for each break point.

David those CSS credit cards are amazing!

David Conner
David Conner
Treehouse Guest Teacher

Blake Boykin Thanks, Greatly appreciated! They were fun to make.

pat barosy
pat barosy
6,759 Points

I agree with Blake, your project is amazing. Some of the code I can follow, some not so much. Did you use SASS on this project? How long did it take you to learn how to do something like that.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,861 Points

You use percentages instead, it talks about it in the next video.