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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:27:30+00:00 2026-05-14T21:27:30+00:00

I have the following HTML. <ul> <li> <a>asdas</a> </li> </ul> In my CSS stylesheet

  • 0

I have the following HTML.

<ul>
  <li>
    <a>asdas</a>
  </li>
</ul>

In my CSS stylesheet I have general settings for the a tag, and several hundered lines later settings for ul li a.
Like this:

a:link
{
 color: red;
}
...
ul li a
{
 color:blue;
}

Firebug tells me, that first the color:blue is loaded, and afterwards overriden by color:red
So far I’ve always thought, that the order of loading css files and the order of style inside a single css file tell the browser how html elements should be formatted. Unfortunately I’m now experiencing it vice versa.

So tell me, how must I correct my style to achieve the a tag inside the li to be rendered blue and not red?

  • 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-14T21:27:31+00:00Added an answer on May 14, 2026 at 9:27 pm

    Styles are applied according to which styles are most specific to the element; among rules that have equal specificity, the last matching rule in the CSS text wins. (There’s also a new concept of "layers" I won’t go into here.) More in the spec. Because a:link is more specific than ul li a, that style wins regardless of placement.

    For the purposes of calculating specificity, the browser (and other tools that process CSS) use numbers with three columns:

    • Column 1: The number of ID selectors
    • Column 2: The number of CLASS selectors (and similar), such as .class (a class selector), :hover (a pseudo-class selector), and attribute selectors like [type=button]
    • Column 3: The number of TYPE selectors, like a or ul as well as ::before and such

    Each column is more significant than the one after it (just like in decimal numbers, where in the number 123, the 1 is more signfiicant than the 2, which is more significant than the 3).

    a:link comes out as 0-1-1 because it doesn’t have any ID selectors, has one class selector (:link), and has one type selector (a). ul li a comes out as 0-0-3, because it doesn’t have any ID or class selectors, but has three type selectors. 0-1-1 is more specific than 0-0-3 because the leading 0s are the same, but 0-1-1 has a 1 in the second column where 0-0-3 only has a 0 (so we ignore the third column, since the second column is more significant than the third).

    So tell me, how must I correct my style to achieve the a tag inside the li to be rendered blue and not red?

    Make the blue rule at least as specific as the red rule. In this case, you can do that by adding :link to it:

    ul li a:link {
        color:blue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following HTML and CSS, now I would like to position my popup
Suppose I have following html page. <html> <head> <link type=text/css rel=Stylesheet href=css/some.css /> </head>
I have the following html and css code: <!DOCTYPE HTML> <html> <head> </head> <body>
I have following Html file with javascript. This gives me error that testCircle is
I have following HTML where hover grows div downwards but I would like to
I have following html. How can I get this so that dragDiv is shown
I have following html code. In my page there are many tag which have
I have following html markup. I want to add this mark up to master
I have following setup: html: <div id=holder> <div> <img/> <img/> </div> </div> css #holder
I have the following html: <label class=description>Label Text</label><input type=password /> And the css styles

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.