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
Learning Coding
7,134 PointsCSS Pixels
Could somebody explain what exactly a pixel is in the context of CSS? How do I know how many pixels to choose? If I am just writing a blog post, how many pixels would I choose When would I use em instead of pixels? Thanks!
2 Answers
David Schriever
1,777 PointsHello Karen, actually there is almost a whole science behind this by now, which can be read up on W3C as far as I know. A pixel is basically the smallest unit on a screen, but in relation to your viewport and the estimated distance you have to that particular screen if I remember right, don't quote me on that.
But honestly all you need to know is 1em is standardly 16px, unless you changed the amount of px, the text size of the parent element has. So an em is always 1 in relation to the size of its parent elements ... So if you, for example change the text-size of the body element to 1.5em, it will now be 24px and elements inside of the body element will calculate, their 1em based on the 24px of the body element.
Let me know if that helps
Alexander Davison
65,469 PointsA pixel is one tiny unit on any computer screen.