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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:40:29+00:00 2026-05-11T01:40:29+00:00

Lets say I have 5 pages: A, B, C, D, and E. I also

  • 0

Lets say I have 5 pages: A, B, C, D, and E. I also have a horizontal menu, and each item has a light gray background.

Each menu item has a:hover that gives it a medium-gray background, but I want the active page to have a black background, so I define

#black {     background-color: #000; } 

Now when the user is on B.php, I want the B menu item to carry the #black id. What is the best way of doing this?

  • 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. 2026-05-11T01:40:29+00:00Added an answer on May 11, 2026 at 1:40 am

    A suggestion; don’t define what your style ‘is’, define what your style ‘does’. Don’t call it #black, instead call it .current.

    Another thing to note is that ID’s are meant for identifying unique elements (#header, #footer, #main, #sidebar, #navbar, etc.). Defining a repeatable item as current should be done with a class, since you can have multiple classes associated with an element, but only one ID. Again, that ID is reserved for unique naming.

    .current {     background-color: #000; } 

    To associate this with a page you could set a variable on the page that indicates which page its on, then use an if block, or switch case, to add the style to the element that relates to the current page:

    (pseudo code, my PHP syntax is rusty)

    $current_page = 'B'  // -- snip --  <ul>     <li id='navigation-a' <? if ($current_page == 'A') { ?> class='current' <? } ?> >Page A</li>     <li id='navigation-b' <? if ($current_page == 'B') { ?> class='current' <? } ?> >Page B</li> </ul> 

    Optionally you could try deriving $current_page from the page url in the request.

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

Sidebar

Related Questions

Lets say I have a main page which has a link that opens a
Let's say I have a page that loads pages dynamically. As each page loads
lets say i have two pages links.html & contents.php ... first page contains only
Lets say I have the following pages: # Include.asp <% Response.Write IsIncluded() & <br>
Lets say there are two pages with two different html elements which have the
I have a web app that has lots of pages with a URL of
For example, lets say I have a page and 2 custom controls on that
Lets say I have a parabola. Now I also have a bunch of sticks
Lets say we have an average of one page fault every 20,000,000 instructions, a
Lets say you have a fragment of the page which displays the most recent

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.