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 trialRyan B.
3,236 PointsTrying to wrap my head around the "compounding effect". Can someone try and explain it using a different approach?
Thanks in advance.
10 Answers
Aaron Smith
19,091 PointsHey Ryan, the compounding effect is based purely upon the fact that any value specified in ems for a given property is going to be rendered by the browser based on its parent element's value for the same property. Check out this generic example:
<div>
<p>This text may be bigger than you expect!</p>
</div>
div {
font-size: 1.5em;
}
p {
font-size: 1.25em;
}
Normally, you'd expect a font-size of 1.25em to render at 20px (1.25 x default font size of 16px = 20px). However, in this case it compounds on its parent's font-size of 1.5em, leaving it to render at 16px x 1.25 x 1.5 = 30px. But it doesn't necessarily stop there. If, for instance, the div element were inside a body element whose font-size was also specified in ems, that value would become a part of the equation too. This is the compounding effect. You could maybe think of it like a snowball effect. The font-sizes snowball on top of each other and create an end-result that might be much different than you want.
Dale Coleman
6,365 PointsMuch appreciated, Aaron. My head started spinning for a second while watching the video. Your breakdown was super helpful.
Jan Wessels
3,982 PointsVery helpful explanation Aaron, helped me to understand the compounding effect.
Daniel (Kwasi) Twum-Acheampong
1,952 PointsDid a quick google search after watching this video in attempt to clear that up but this is the best explanation I've received thus far! Thank you Aaron
Karl Pupé
6,718 PointsBrilliant answer! Thanx Aaron!
Kailash Seshadri
3,087 PointsBrilliant answer Aaron!! I was so confused after watching the video!!
cassandraarchibald
4,429 PointsThank you Aaron! I was a bit lost after watching the video but feel I understand now :)
Wioleta Celinska-Drozd
6,615 PointsThanks Aaron, the best explanation of this concept i could find! :)
ibrahim Warsame
7,803 PointsThanks dud.
Orion Ford
2,100 PointsIncredible delivery!
Ryan B.
3,236 PointsRyan B.
3,236 PointsThanks Aaron. Your answer was very helpful.
Christopher Mayfield
19,928 PointsChristopher Mayfield
19,928 PointsGreat answer Aaron! This wasn't as clear in the video. Appreciate it!
Callie Sitek
1,796 PointsCallie Sitek
1,796 PointsThanks for this! Really helped clear up the idea of compounding ems.
Andrew Ames Fuller
7,100 PointsAndrew Ames Fuller
7,100 PointsDitto!
reenadee
1,437 Pointsreenadee
1,437 PointsThank you!! Excellent, clear explanation. Much appreciated.
Amanda Thompson
2,594 PointsAmanda Thompson
2,594 PointsThanks very much indeed. Your example with the math illustrates the relations in the compounding effect. Had watched the video three times and read the transcript but could not understand why/how the em was 'changing' i.e. where the new bigger numbers were coming from. The first example set was linked to an absolute number of 16px made sense but the last example was baffling.