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 4260298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:54:05+00:00 2026-05-21T05:54:05+00:00

My Website On the link above you can see that I have a CSS

  • 0

My Website

On the link above you can see that I have a CSS drop down menu in my site. It works fine, however, I want the top level items to stay highlighted when I’m on the page they represent.

I have this so far but it won’t work (I’m only showing one menu item which doesn’t have any sub menus as it saves space)

Here’s the HTML:

<ul>
    <li><h2><a name="donate" id="donate" href="index2.php?op=Donate">Donate</a></h2></li>
</ul>

Here’s the CSS that colours the background:

#menu a {
color: #000;
background: #efefef;
text-decoration: none;
}

The content of each page is determined by the value of $head: $head = $_GET[‘op’];

I tried to implement the change by placing this straight after the menu:

if($head == "Donate") {
echo '<style>
#menu a donate {
color: #000;
background: #fff;
text-decoration: none;
</style>';
}

When I leave ‘donate’ out of the above code: ‘#menu a {‘ the background color of all the menu items changes to white, but I need to change the ‘donate’ button specifically. I tried doing this by adding id=”donate” / name=”donate” to the menu item (as seen above), and then calling it in css with ‘#menu a donate {‘. but that is obviously wrong as it doesn’t work! What should I do?

  • 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-21T05:54:06+00:00Added an answer on May 21, 2026 at 5:54 am

    OK, quick and dirty answer : your CSS selector wont work, because right now it search for a tag “donate” inside a “a” tag inside a tag with the id “menu”. I assume all your link have a specific Id, so the easy way to do it is to use this selector

     #donate
     {
         color: #000;
         background: #fff;
         text-decoration: none;
     }
    

    As an added bonus, this selector will be faster to parse by the browser.

    By the way, you seem not to close the style tag. Is that an error?

    Now, for a longer answer, it is not exactly the best way to do it. I suggest you create a CSS class with a name like “currentpage” and to use it like this in your menu

    <li><h2><a <?php if($head == "Donate") echo 'class="currentpage"'; ?> id="donate" href="index2.php?op=Donate">Donate</a></h2></li>
    

    That way you can keep your style in the stylesheet where it will be easier to maintain. Now of course, if all your menu tags are handcoded, you may find it pretty tedious to add the condition in everytag. If it’s indeed the case, I suggest you create your menu using a loop.

    By the way, you should remove the name attribute in the a tag, its a deprecated feature. id does the job just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Website As you can see on the above link there are several 'kids',
I am building a website www.etutornetwork.com, in top menu I have included a link
-- link removed -- How can I convert the numbers in the above website
Take a look: a link . You can see that the icons at the
i have a website where i provicde a link. On clicking the link a
Ive a website that create avatars for users and provide them with link for
My website utilizes ASP. I have a link to a PowerPoint file within my
I am downloading a file from a website and I have the link. But
I have a website with a fixed background and another little image that is
My issue is following: My Partner's have websites and I want that partners can

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.