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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:36:17+00:00 2026-06-07T09:36:17+00:00

I am creating a navigation bar right now and I want the width of

  • 0

I am creating a navigation bar right now and I want the width of the main elements on the navigation to be auto, but sub elements to all be a fixed width. The way the list is made is as such:

    <li>Main Element
        <ul>
        <li> Sub Element </li>
        <li> Sub Element </li>
        <li> Sub Element </li>
        </ul>
    </li>

This is repeated for each main menu item and its submenu items.

The issue I am having is I want to css for the sub elements to be 100px in width, but the main elements to be equal to the text size plus 10px of padding on both the left and right. It appears I can not change one without changing both, even after attempting to make classes to separate them. I have also tried editting ul li and li ul styles in my external style sheet. Thank you in advance for all help.

  • 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-07T09:36:19+00:00Added an answer on June 7, 2026 at 9:36 am

    ul li affects all li‘s at any level under an ul. ul > li only affects the li‘s that are direct children of an ul. It’s called a child combinator: http://www.w3.org/TR/css3-selectors/#child-combinators

    You must use it if you are to make it happen without using classes (using classes would actually be the better way imo – http://www.jsfiddle.net/joplomacedo/xeWA4 )

    The trick is applying the styles you want applied on the main menu items under ul > li and then override them at ul ul > li. Here’s a fiddle – http://jsfiddle.net/joplomacedo/xeWA4/3/

    EDIT:
    You actually don’t need to use the child combinator at all. Child combinators came to my mind
    when I first read your question, and I kind of never questioned their use. So, ul li overridden by ul ul li works perfectly as well – and keeps it simpler.

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

Sidebar

Related Questions

I'm creating a navigation bar and its made using an unordered list. I want
I had this idea for a website of creating a fixed horizontal navigation bar
I'm creating a horizontal ul navigation bar. Each li item is a different width.
First off I'm new at programming. I'm creating an app with one navigation bar
I have a button as the right button on my navigation bar: UIBarButtonItem *addButton
I am creating a reference app which has a navigation bar at the top
When creating a UIView with a navigation bar in interface builder, the top bar
I am adding a custom background image to my navigation bar by creating an
When I am putting two right bar buttons in my navigation bar at that
I'm creating an App for Ipad, I created 3 views with a navigation bar

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.