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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:50:53+00:00 2026-06-04T01:50:53+00:00

HTML : <ul id=menu> <li><a href= class=active>Portfolio</a></li> <li><a href=>Services</a></li> <li><a href=>About</a></li> <li><a href=>Testimonials</a></li> <li><a

  • 0

HTML:

<ul id="menu">
    <li><a href="" class="active">Portfolio</a></li>
    <li><a href="">Services</a></li>
    <li><a href="">About</a></li>
    <li><a href="">Testimonials</a></li>
    <li><a href="">Request a Quote</a></li>
</ul>

CSS:

ul#menu li {
    display:inline;
    margin-left:12px;
}

Is there a difference between using “ul#menu li” and just “#menu li“? I used both versions and they seem to accomplish the same thing. Is there a reason why most tutorials use add the “ul” before the id?

  • 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-04T01:50:54+00:00Added an answer on June 4, 2026 at 1:50 am

    There is one obvious difference and one more subtle difference.

    The obvious difference is that #menu targets all elements with the ID #menu, whereas ul#menu only targets ul elements. If you only give the ID #menu to ul elements, the selectors will always have the same result.

    There is one potential difference with something called specificity. This is a way of determining which rule to use in case of conflicts. So if you have these two rules:

    #menu li {color: blue;}
    ul#menu li {color: red;}
    

    the second rule will win, because it is more specific, and the text will be red. The rules for specificity are complex and not always intuitive, but in this case the simple result is that ul#menu li is slightly more specific than #menu li. If you only have one stylesheet, this is unlikely to be an issue for you. If you have several stylesheets, it can be confusing to work out why a certain rule is being ignored; specificity is often the answer.

    As to why most tutorials use ul#menu, I don’t know. (In fact, I only have your assertion as evidence that they do!) My guess is that they are making things Really Very Obvious for the sake of idiot readers.

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

Sidebar

Related Questions

i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I want to set an active class for a CSS image menu. I tried
In menu.html, I have my menu items(a href links), let's call them, menu_1, menu_2,
In my case, I have an HTML/CSS Menu in the site master . So,
<body> <div id=header> <div class=title>SPORTS STORE</div> </div> <div id=categories> <% Html.RenderAction(Menu, Nav); %> </div>
I have a html/css based menu and I'm trying to put a flash video
html- <div class=hbg> </div> some menu items here jquery for mouser over on menu
I have the following menu in my masterpage: <ul id=menu class=lavaLampBottomStyle> <li> <%= Html.ActionLink(Employees,
How to define that one of menu items is active by default? /* CSS
I have the following HTML: <ul class=vertical_menu no_select> <li class=edge_top>&nbsp;</li> <!-- Menu Items Here

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.