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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:08:17+00:00 2026-06-17T18:08:17+00:00

I am in the process of styling a navigation. This navigation has a sub-menu

  • 0

I am in the process of styling a navigation. This navigation has a sub-menu dropdown, with the potential of a secondary dropdown within that dropdown. In essence I have two layers of sub-navigational items.

Here is my problem: I have a hover state on my outermost parent item, lets call it “About Us”. A dropdown menu beneath it appears with further links, when I move the mouse into this dropdown, a different hover state activates for those links. My problem, is the hoverstate on the “About Us” link disappears. I want that hover state to stay active. So far this navigation is purely done with CSS, no javascript is used, and I would like to stick with CSS completely if possible.

Each UL has a class, for example .main-nav for the parent UL, and .main-sub-nav for the subnav elements.

Trying to be creative, I thought I could say for example(the example assumes #ccc is the highlight color for the parents hover state:

.main-nav li a:hover {background: #ccc;}    
.main-sub-nav li a:hover .main-nav li a {background: #ccc;}

This doesnt work, I assume because I am trying to reference a parent element from a child element, it doesn’t understand what I am doing. Is there a similar method to what I am doing above to achieve this?

Sample HTML Structure:

<nav>
    <ul class="main-nav">
        <li><a href="#">Home</a></li>
        <li><a href="#">About Us</a>
            <ul class="main-sub-nav">
                <li><a href="#">About Sub 1</a></li>
                <li><a href="#">About Sub 2</a></li>
            </ul>
        </li>
        <li><a href="#">Contact Us</a></li>
    </ul>
</nav>

You can see this code in full at the following dev site: http://khill.mhostiuckproductions.com/siteLSSBoilerPlate/

Note when you hover over About us, and move your mouse down into the subnav, the highlight on about us disappears.

Like I said I’d like to solve this with purely CSS, and preferably, without adding classes to anything. This becomes complicated as this nav is generated fully with PHP and adding more classes just gets nasty.

  • 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-17T18:08:19+00:00Added an answer on June 17, 2026 at 6:08 pm

    I think this should solve the problem,

    .main-nav > li:hover > a {background: #ccc;}   
    

    DEMO

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

Sidebar

Related Questions

I'm in the process of styling an asp.net menu and I'm trying to understand
I have a layout that looks like this: It's a table with one cell
I have a web project that I am ripping out all the inline styling
I'm currently in the process of styling a website and have hit a bit
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,
I process data with two maps per records, one is (&,=)-formatted (id=111&name=...), the other
I process a lot of text/data that I exchange between Python, R, and sometimes
Now I have discovered Jquery I'm in the process of updating my site. Could
I'd like to apply similar styling to elements like textboxs, checkboxes, etc. that my
I am interested in how other people handle website navigation. Not the styling or

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.