Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

Need to highlight menu item when page is active

I am using php to include a menu on my individual pages which is a common practice. What I'd like to do is highlight the menu item when the corresponding page is active. I've tried a few methods but have been unsuccessful.

Any help is appreciated.
0
J C
Asked:
J C
1 Solution
 
käµfm³d 👽Commented:
When a page is active, give the menu item that represents that page a different CSS class. Simply have two CSS rules in your stylesheet:  one for inactive tabs and the other for the active tabs. Just toggle between the classes as the pages change.
0
 
COBOLdinosaurCommented:
Just give each of the menu tabs a unique id, and then generate a style tag in the head with a single rule for the target id and the highlighting you want:
<style type="text/css">
#idnumber1 {background-color:magenta;}
</style>

Cd&
0
 
J CAuthor Commented:
Thanks, that works.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now