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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:25:17+00:00 2026-06-14T08:25:17+00:00

I need to target css for the first level ul submenu in a parent

  • 0

I need to target css for the first level ul submenu in a parent ul.

CSS:

#menu li:hover > ul.sub_menu { ...some styles }

..but this will ofcourse do it for all the sub_menu’s, I only want this particular style for the first sub_menu relative to the parent when you hover over the parent list item.

HTML:

<ul id="menu">
    <li>Item 
      <ul class="sub_menu"><!-- target only this one -->
       <li>Item
         <ul class="sub_menu">etc...</ul><!-- do not do for this one and so on-->
       </li>
      </ul>
    </li>
    <li>Item 
      <ul class="sub_menu"><!-- target only this one -->
       <li>Item
         <ul class="sub_menu">etc...</ul><!-- do not do for this one and so on-->
       </li>
      </ul>
    </li>
</ul>

Thanks for any feedback…

  • 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-14T08:25:19+00:00Added an answer on June 14, 2026 at 8:25 am

    You can use the :first-child selector:

    #menu > li:first-child > ul.sub_menu {
        color: red;
    }
    

    And then use the descendant selector to revert the changes for the other elements:

    #menu > li:first-child > ul.sub_menu ul {
        color: black;
    }
    

    Demo: http://jsfiddle.net/6y4Sb/

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

Sidebar

Related Questions

I need to decode and specifically target the first url only in this array:
Building my first webapp with jQuery Mobile - this will need to work with
My app need to target API level 7 and above, however I'd like to
I'm working on a sharepoint page and I need to target the top menu
[Revision 5/14/09: I need this to target Dotnet 2.0 because of my deployment scenario]
I need to target the starting tag of the last top level LI in
My web application target to major Smartphones and I need to change the CSS
I need to target a tags with img inside them. Can I do this
Hello im trying to target a specific css background image here http://22twenty.com/This/ What i
Possible Duplicate: Targeting only Firefox with CSS I need to target firefox specifically because

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.