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

  • Home
  • SEARCH
  • 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 8327637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:10:51+00:00 2026-06-09T01:10:51+00:00

I want to make the easiest css for menus. There’s an outer div and

  • 0

I want to make the easiest css for menus. There’s an outer div and an inner anchor. If the outer’s class is the same as the inner’s id, that will be active styled.
Example code:

<div class='<?php echo $_GET['menu']; ?>'>
     <a href="index.php?menu=menu1" id='menu1'>Menu 1</a>
     <a href="index.php?menu=menu2" id='menu2'>Menu 2</a>
     <a href="index.php?menu=menu3" id='menu3'>Menu 3</a>
     <a href="index.php?menu=menu4" id='menu4'>Menu 4</a>
     <a href="index.php?menu=menu5" id='menu5'>Menu 5</a>
</div>

and I don’t want to write a lot of css, like:

.menu1 #menu1, .menu2 #menu2, .menu3 ....
{ /*active stlye*/}

so I want the following: if the classname is the same of the id under it would be active.

Thanks in advance.

  • 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-06-09T01:10:53+00:00Added an answer on June 9, 2026 at 1:10 am

    That’s not possible. CSS isn’t a programming language, you have to fully specify every selector.

    But since you already work with PHP it would be a lot easier if you apply the class to one of your anchor tags:

    <div class='<?php echo $_GET['menu']; ?>'>
         <a href="index.php?menu=menu1" <?php echo $a_class[1]; ?> id='menu1'>Menu 1</a>
         <a href="index.php?menu=menu2" <?php echo $a_class[2]; ?> id='menu2'>Menu 2</a>
         <a href="index.php?menu=menu3" <?php echo $a_class[3]; ?> id='menu3'>Menu 3</a>
         <a href="index.php?menu=menu4" <?php echo $a_class[4]; ?> id='menu4'>Menu 4</a>
         <a href="index.php?menu=menu5" <?php echo $a_class[5]; ?> id='menu5'>Menu 5</a>
    </div>
    

    You have to either specify a bunch of selectors or add code to your PHP script.

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

Sidebar

Related Questions

Want to make a vocabulary list in HTML & CSS that looks like this:
I have style sheet with a class name changebackgroundcolor i want make change in
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
Yes, it's a newb question. I want to make a timetabling application that these
I want to make photos gallery like one in this photo: Is there any
I want to make an app that lets a vendor sell gift cards through
Is there a way to hide commits from certain users? I want to make
I want to make a Tool that enables the user to interact with Windows,
I have developed a few python programs that I want to make available online.
I want make datetimepicker in my project. Using jquery how it is possible? I

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.