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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:23:07+00:00 2026-05-26T11:23:07+00:00

I have a little website with 5 nav sections. For avoid change the code

  • 0

I have a little website with 5 nav sections.

For avoid change the code on every page when I have to add one more sections, I use a php include on the nav section of every page.

Now I need to add class “selected” to the list item (li) depending the page visited. ¿How to do this? Because now the nav is unique.

This is the code

            <nav>
                <ul>
                    <li class="selected"><a href="index.php">Home</a></li>
                    <li><a href="biography.php">Bio</a></li>
                    <li><a href="photo.php">Photo</a></li>
                    <li><a href="work.php">Work</a></li>
                    <li class="last"><a href="contact.php">Contact</a></li>
                </ul>
                <div class="clear"></div>
            </nav>

Thanks!

  • 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-26T11:23:07+00:00Added an answer on May 26, 2026 at 11:23 am

    Here’s the easy way to do it, pure CSS no need for any programming: Add an ID to your body and your links:

    <body id='home'>
        <nav>
            <ul>
                <li id='home-link'><a href="index.php">Home</a></li>
                <li id='bio-link'><a href="biography.php">Bio</a></li>
                <li id='photo-link'><a href="photo.php">Photo</a></li>
                <li id='work-link'><a href="work.php">Work</a></li>
                <li id='contact-link'class="last"><a href="contact.php">Contact</a></li>
            </ul>
            <div class="clear"></div>
        </nav>
    

    Now, you just style like this:

    #home #home-link, #bio #bio-link, #photo #photo-link, #work #work-link, #contact #contact-link{
        //however you would have styled .active
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our website code is written in PHP. We have very little testing in regards
I have a little problem with my website. People use this page to create
I have a little website with a few users and I'd like to add
I have a little experience in php and I am making a website for
I've been stuck on a little unix command line problem. I have a website
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I'm writing a little website (webapp) in php+codeigniter, I'd really like to make it
I have very little experience with setting up a website from scratch in a
I'm working on this website, and have a little thorn in my side. When
I've designed a nifty little website that uses phpflickr (the PHP Flickr API) to

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.