wordpressmenu

How to make current page active using CSS?


How do I make the current page active in my menu? I would like to display an active or hover effect on the menu item of the page I am currently on. For example, if I visit the contact page, the contact page menu item should automatically show the active/hover effect in the main/primary menu.

I tried using this CSS code: .mainmenu .current_page_item a, but it didn't work. The class for my main/primary menu is .mainmenu.


Solution

  • Have you take a look at your source code?

    Please make sure that mainmenu is a class. Maybe it's an id ...

    So you can try this: #mainmenu .current_page_item a