I am new to developing web pages. I am looking to create menus similar to the ones in stackoverflow.com (like Questions, Tags, Users shown above). How do I change the color of the selected menu (for example, the background color of the Question changes to orange when 'clicked')?
I have managed to change the color while hovering (using CSS) as that was simple, but I am having trouble with this.
Can I achieve this effect of changing the color of a clicked item using only CSS?
Set the styles for class active and hover:
Than you need to make the li active, on the server side. So when you are drawing the menu, you should know which page is loaded and set it to:
But if you are changing the content without reloading, you cannot change set the active li element on the server, you need to use javascript: