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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:49:41+00:00 2026-06-12T13:49:41+00:00

I have a list and list also has list in it. I set styles

  • 0

I have a list and list also has list in it.
I set styles on parent list but I want different styles for parent and child list but they are mixed somehow I can’t separate them.

HTML file:

<ul id="accountNavigation">
  <li><a href="#">Something</a></li>                    
  <li id="userNavigation">
    <img src="https://si0.twimg.com/profile_images/135460415/UAB_dragon_head_normal.png" alt=""/>
    <a href="#">Username</a>
    <div class="showme">
      <ul id="userNavigationSubMenu">
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>

      </ul>
    </div>
  </li>
</ul>

CSS file:

body{background:#ff0000;}
#accountNavigation{ list-style: none;float: right;height: 44px;}
#accountNavigation li{ float: left;color: #fff;height: 44px;}
#accountNavigation li:hover{ background: #ddd;cursor: pointer;}
#accountNavigation li a{ text-decoration: none;color: #fff;line-height: 44px;font-weight: bold;font-size: 13px;height: 44px;padding: 15px 27px 0 14px;outline: none;}
#accountNavigation li img{ position: absolute;top: 12px;left: 10px;width: 22px;height: 22px;}
#userNavigation{position: relative;}
#userNavigation a {padding-left: 38px !important;}

#userNavigation{}
#userNavigation:hover{}
#userNavigation:hover .showme{display: inline;}
.showme
{
  display: none;
  width: 140px;
  height: 200px;
  background: #f5f5f5;
  margin: 0px auto;
  padding: 10px 5px 0px 5px;
  border: 1px solid #ddd;
  border-top: none;
  z-index: 10;
  position: absolute;
  right:0;
  top: auto;

}
#userNavigation ul { list-style: none;}

This is fiddle.

  • 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-12T13:49:42+00:00Added an answer on June 12, 2026 at 1:49 pm

    Simply use the > direct/immediate descendant combinator, and an id to specify which li (or ul) elements you’re targeting:

    #accountNavigation { /* outer ul element */
    }
    
    #accountNavigation > li { /* outer ul element's children li */
    }
    
    #accountNavigation > li > ul { /* first 'inner' ul element */
    }
    
    #accountNavigation > li > ul > li { /* first 'inner' ul element's li children */
    }
    

    You can, of course, be more generic and simply use:

    ul { /* targets all ul elements */
        /* general styles */
    }
    ul li { /* targets all li elements within a ul */
        /* general styles */
    }
    ul li ul { /* targets all ul elements within an li element, itself within a ul */
        /* overrule general 'outer' styles */
    }
    ul li ul li { /* targets all li elements within a ul element,
                     within an li element, itself within a ul...and so on */
        /* overrule general 'outer' styles */
    }
    

    Using the general approach:

    <ul>
        <li>This should be green!</li>
        <li>This is also green...
            <ul>
                <li>But this is not, it's, um...blue!</li>
                <li>And so on...</li>
            </ul></li>
        <li>This is green too, just because.</li>
    </ul>
    

    The following CSS should demonstrate its use:

    ul li {
        color: green; /* the 'general'/'default' settings */
        margin-left: 10%;
    }
    
    ul li ul li {
        color: blue; /* this overrides the 'general' color setting */
                     /* the margin is not overridden however */
    }​
    

    JS Fiddle demo.

    References:

    • CSS Selectors (Level 3), at the W3.org.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of content items, each with a set width but different
I am using Drupal and have sifr set on list items, and also a,
I have a list of items. Each of them has a set of data
I have a class that is inherited from List<T> and also has some properties,
Context I have a list of items I also have a structure with s
I have a list on SharePoint with several hundred items in it. I also
I have a list of phone numbers that have been dialed (nums_dialed). I also
I have a long command saved in a file. I also have a list
I have a URL list of jar files, also I have whole path classname
I have a class that requires dynamically setting a List. I also call this

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.