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

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When benchmarking C++ comtainers, it's important to enable most compiler… May 12, 2026 at 12:21 am
  • Editorial Team
    Editorial Team added an answer The call to redirect() issues a HTTP redirect. Nothing happens… May 12, 2026 at 12:21 am
  • Editorial Team
    Editorial Team added an answer From the Wikipedia article on conditional comments (modified to fit… May 12, 2026 at 12:21 am

Related Questions

I'm mostly familiar with Java, C and C++ in which there are ways to
I need to setup an image menu. The client wants a specific font and
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
Problem: I have a set of images, lets say 5. There is an structure

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.