Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6006725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:34:51+00:00 2026-05-23T01:34:51+00:00

I am new to developing web pages. I am looking to create menus similar

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:34:52+00:00Added an answer on May 23, 2026 at 1:34 am

    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:

     <li class="active">Question</li>
     <li>Tags</li>
     <li>Users</li>
    

    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:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <style>
      .menu{width: 300px; height: 25; font-size: 18px;}
      .menu li{list-style: none; float: left; margin-right: 4px; padding: 5px;}
      .menu li:hover, .menu li.active {
            background-color: #f90;
        }
    </style>
    </head>
    <body>
    
    <ul class="menu">
    <li>Item 1</li>
    <li class="active">Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
    <li>Item 5</li>
    <li>Item 6</li>
    </ul>
    
    <script type="text/javascript">
    
    var make_button_active = function()
    {
      //Get item siblings
      var siblings =($(this).siblings());
    
      //Remove active class on all buttons
      siblings.each(function (index)
        {
          $(this).removeClass('active');
        }
      )
    
    
      //Add the clicked button class
      $(this).addClass('active');
    }
    
    //Attach events to menu
    $(document).ready(
      function()
      {
        $(".menu li").click(make_button_active);
      }  
    )
    
    </script>
    </body>
    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP.Net Am New to website development Currently am developing a web pages, when
I am developing a set of new pages for an existing (and large) web
I'm developing new web app with Struts2 framework, eclipse, and I've mapped the db
I'm new to web developing. This is part of a phone service, and I'm
I'm developing a web application for a new service, starting from Firefox 3.5. The
I am a new ASP.NET developer and I am developing a web-based suggestions box
I'm developing a new set of web services at my company. My manager asked
I am new to windows phone. I am developing a web-app and the test
Help I'm very new with web developing using ASP.NET. Why is the my web
Good Morning All, I am developing a new ASP.net MVC web application. Part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.