Yes, very much possible and you don’t even have to add classes yourself. If you’re using wp_nav_menu, WordPress adds classes for every case the specific nav item is in. I’ll name the important classes for Publications (amongst others), based on where you clicked hypothetically:
-
Publications – This is now the selected item, and will get (amongst others) the classes:
current-menu-itembecause it’s selected -
Computers – Publications is not the selected item, but will get the classes:
current-page-parentandcurrent-menu-parentbecause it’s direct child is the selected item, andcurrent-page-ancestorandcurrent-menu-ancestorbecause one of it’s children down the line is the selected item -
Article 123 – Publications is not the selected item, but will get the classes:
current-page-ancestorandcurrent-menu-ancestorbecause one of it’s children down the line is the selected item
So in short, current-menu-item when selected, [classname part]-parent when direct child is selected and [classname part]-ancestor when child, grand-child or deeper level child is selected