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

PHP Build a Simple PHP Application Creating the Menu and Footer Adding Active States to the Navigation

Matthew Smart
Matthew Smart
12,567 Points

<?php if ($section == "shirts"){echo "on";}?>

how is the term 'echo "on" ' relating to css format?

Matthew Smart
Matthew Smart
12,567 Points

Im understanding php, also understanding html and css really good. But echo "on" i would imagine would just print out 'on' on the page, so how does it link to css?

Lucas Santos
Lucas Santos
19,315 Points

It links to the CSS because you are using the echo command (which prints a word) inside the class of the element (where it would say class="<?php if ($section == "shirts"){echo "on";}?>"). So in your CSS you already have a class set to .on with some styling applied. So in other words you print that word "on" into the class and setting it to the class of "on".

Lucas,

You should post your comment as an answer.

3 Answers

Lucas Santos
Lucas Santos
19,315 Points

It links to the CSS because you are using the echo command (which prints a word) inside the class of the element (where it would say class="<?php if ($section == "shirts"){echo "on";}?>"). So in your CSS you already have a class set to .on with some styling applied. So in other words you print that word "on" into the class and setting it to the class of "on".

it's when you click on the nav button like shirt, the shirt page verify if section = shirt then active navbar button color is actived else is not activated so the css is not applied.

Matthew Smart
Matthew Smart
12,567 Points

Thanks for answering guys, i understand it now, just the video didn't explain it like that. :)