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 trialAnthony Fowler
6,749 PointsMy Code works as shown but I am wondering how or why echo " on" has this effect.
It seems to be that the underlining of the nav element is possibly done through CSS and This echo "on" is possibly creating a class? I don't quite understand what is happening here. Any help would be much appreciated!
1 Answer
Dave Faliskie
17,793 PointsThe purpose for using the echo " on" is to add the class .on (which just underlines the text) to the nav link if it meets the condition set.
So what that php code is doing is comparing the $section variable, set on each page, to the name of the link. Ex. the $section = 'book' means your on the book page so echo " on". Or in other words if they are the same add the class "on"