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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:39:19+00:00 2026-05-21T20:39:19+00:00

This is the html code i am using……. <ul id=top_options> <li>Discussions</li> <li>Tags</li> <li>Users</li> <li

  • 0

This is the html code i am using…….

<ul id="top_options">
<li>Discussions</li> 
<li>Tags</li> 
<li>Users</li>
<li class="selected_top_option">Unaddressed</li> 
<li>New Discussion</li> </ul>

and this is the CSS part i am using for the above code…

#top_options
{
    display:inline;
    float:left;
}
#top_options li
{
    list-style:none;
    display:inline;
    margin-right:20px;
    background-color:#ADADAD;
    color:#FFF;
    font-size:16px;
    font-weight:bold;
    line-height:50px;
    padding-left:8px;
    padding-right:8px;
    font-family:Arial, Helvetica, sans-serif;
}
#top_options li:hover
{
    background-color:#FF8000;
    cursor:pointer;
}
.selected_top_option
{
    background-color:#F00;
    border:dotted;
}

The Problem is the ‘Unaddressed’ list item should be displayed in #F00 background color, but it is being displayed in #ADADAD background color, but it is getting the border specified. What is the point i am missing here.?

  • 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-21T20:39:20+00:00Added an answer on May 21, 2026 at 8:39 pm

    It’s because of specificity – when you define the same CSS attribute in two different ways for the same element, the CSS attribute in the more specific selection method is the one applied.

    #top_options li is more specific than .selected_top_option and so its definition of background-color is the one applied. Think of it this way – there can only be one thing with that id so that is very specific, but there can be many things with that class, so that is less specific. As such, the id wins out.

    Based on the linked HTML Dog article (this isn’t exactly how specificity is calculated, as it ignores !important for instance, but it’s a great quick and easy calculation method), the specificity is:

    .selected_top_option = 10 (1 class selector)
    #top_options li = 101 (1 id selector + 1 element selector)
    

    So in this case, 101 is higher (i.e. more specific) and wins out whenever there’s a conflict between these two.

    Another good article on specificty is this Smashing Magazine article and there are plenty more on Google.

    The solution is to make .selected_top_option more specific. I’d recommend either:

    #top_options li.selected_top_option { /* your css here */ } 
    .selected_top_option { background-color: #F00 !important; /* rest of css */ }
    

    However, I’d recommend against the !important in most cases, simply because it makes it more complicated to override later.

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

Sidebar

Related Questions

I'm using this HTML,CSS and Javascript code (in one document together if you want
I am using jquery Mobile 1.0. I have this html code. <label for=slider class=ui-hidden-accessible>
I'm using this HTML code: <form action=# method=post> <fieldset> <label class=desc id=title10 for=Field10> How
I'm using http://code.google.com/p/flex-iframe/ for showing html in an flex application. To set this up
I'm trying to parse a html doc using some code I found from this
i using jquery and jquery-ui, this is my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
i have this html code. Im using Simple HTML Dom to parse the data
I have this html code: <tr> <td><label><input type=text name=id class=DEPENDS ON info BEING student
Hi i have this HTML code: <tr class=odd events style=> <tr> <a title=Expand to

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.