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

CSS

Liam Maclachlan
Liam Maclachlan
22,805 Points

-4px or 0em? How do you get rid of your white space?

So, on this part of the course, I was curious as to why the -4px/-0.25em method was taken.

Especially with navigation, I have normally done this.

ul {
font-size: 0em;
}

li {
font-size: 1rem;
}

This will get rid of the white space by setting the font size on everything between the LI and UL element to 0. But, the LI will remain as the default font size. Is there a reason, in your opinion, why this approach was taken? Is what I'm doing a bad habit?

4 Answers

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Liam Maclachlan,

I wouldn't say it's a bad habit. Checkout this related Community thread on the subject.

Liam Maclachlan
Liam Maclachlan
22,805 Points

Ah. That's cool, man. I get that the -4px approach works but I think the angle I'm trailing off on is scalability but that really isn't this courses main focus :)

Maxim Andreev
Maxim Andreev
24,529 Points

I really like your approach Liam, actually prefer it over the one in the video since I use ems/rems for my font sizes.

Quinn Zepeda
Quinn Zepeda
15,175 Points

Sort of on this topic, but when I do this exercise if I use -4px or -.25 em i get a single line that will change from between donuts and tea to between tea and coffee, but by changing it to -5px or even just -.26em it looks just like the video. Chrome on windows 10

Mark Foster
Mark Foster
6,277 Points

I was wondering about this, I had the same outcome. -5px fixed it for me as well. Thanks for noting a resolution.

I like Liam's approach more, but as he mentioned, this is not the main topic of the video :)