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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:14:19+00:00 2026-05-18T00:14:19+00:00

I have built a CSS navigation header, and it’s working exactly the way I

  • 0

I have built a CSS navigation header, and it’s working exactly the way I want in regards to positioning, stylization, all that. This is the CSS that stylizes it:

#header ul {
padding:72px 0 0 0;
text-align:center;
}

#header ul, #header ul li {
margin:0;
list-style:none;
}

#header ul li {
display:inline;
}

#header ul li a {
font-size:17px; color:#69C; text-decoration:none;
display:inline-block;
height:44px;
line-height:44px;
margin:3px 6px;
padding:0 26px;
}

#header ul li a:hover {
background:#69C;
color:#FFF;
}

And this is the list:

<div id="#header">
   <ul>
      <li><a href="#">HOME</a></li>
      <li><a href="#">WHAT WE DO</a></li>
      <li><a href="#">ABOUT US</a></li>
      <li><a href="#" id="get_started">GET STARTED TODAY!</a></li>
   </ul>
</div>

Pretty simple stuff (and currently viewable at http://www.pmind.com/staging, but I included the code here for potential future readers).

You may notice in the list, the final li has an ID assigned to it. When I add this rule to the CSS:

#get_started {
color:#3C0;
}

Nothing happens. It was my understanding that A. CSS rules that come later in the CSS document have priority over rules that come earlier, and B. CSS rules used with the ID selector had the highest priority no matter what. But clearly the blue colourization that comes from the earlier CSS rules is still taking priority over colouring the final li green. I tried to make sure I did my due diligence Googling for the solution, but everything I find says that IDs get the highest priority (and this has also been my understanding in practice for everything I’ve coded before this one issue).

  • 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-05-18T00:14:20+00:00Added an answer on May 18, 2026 at 12:14 am

    If you were trying to override a selector that didn’t have an ID with one that did, your confusion would be spot on.

    In this case, though, you’re using #get_started (which has an ID) to override #header ul li a which also has an ID in it.

    Surely you’re thinking that your ID is more specific than the #header ID — and you’re not entirely wrong — but that’s not how CSS works. It only cares about the number of IDs used in the selector, not which elements those IDs happen to target.

    To figure out which of two selectors takes precedence, first count the IDs in each. If one has more IDs than the other, it wins and you’re done.

    If it’s the same number (in this case both have one) move on to the number of classes. Again, if one has more classes than the other, it wins and you’re done. In this case, both have zero classes.

    So we move on to the number of tag names. Once again, if one has more tag names it wins. And here #header ul li a has three tags in it (ul, li, and a) whereas #get_started has none. You lose. The existing selector wins.

    You could work around this with just #header #get_started which now has two IDs, but my preference would be to more clearly describe it as:

    #header ul li a#get_started
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built an application that uses SQL Express 2005 and I want to
I have built an MSI that I would like to deploy, and update frequently.
I have built an application in C# that I would like to be optimized
I have built a .dll under WinXP that claims it can't find DWMAPI.DLL when
I have built a MS Access 2007 application that can create reports files in
I have built a simple C#.Net app on a M/C with only .Net FX
I have built a web page which contains a Crystal Report built using the
I have built a number of asp.net servercontrols into a class library, & I
I have built a CFC designed to serve as a dynamic, aging cache intended
I have built a windows service application in VB.net 2008, and used the Setup

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.