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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:51:07+00:00 2026-05-27T06:51:07+00:00

i have this css rule in my stylesheet for a link list. the first

  • 0

i have this css rule in my stylesheet for a link list. the first is a general rule for the <a> tags and the last two are specific rules for the first and last child with fail-overs for the first-child and last-child pseudo-classes

/* weight: (1 class) + (3 elements) = 13 */
.topNavigation ul li a { 
color: #666;
text-decoration: none;
display: block;
font-size: 28px;
margin: 5px 20px;
}

/*for both rules: (1 class + [1 pseudo class or 1 class]) + (3 elements) = 23 */
.topNavigation ul li:first-child a, .topNavigation ul li.first-child a {
margin-left: 0;
}
.topNavigation ul li:last-child a, .topNavigation ul li.last-child a {
margin-right: 0;
}

the html is this:

<div class="topNavigation">
<ul>
    <li class="first-child current">
        <a href="#">home</a>
    </li>
    <li>
        <a href="#">services</a>
    </li>
    <li class="last-child">
        <a href="#">blog</a>
    </li>
</ul>
</div>

the general idea is that the links are contained in <li> and are “margined” away from the edges of the <li>. the problem is that IE8 is NOT honoring the specificity and is still using the margins stated in the first rule (the margin: 5px 20px;). I have tested it in IE7, IE9, chrome and other browsers and only IE8 is not following.

anything wrong with this rule? or am i overseeing an IE8 bug?

  • 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-27T06:51:07+00:00Added an answer on May 27, 2026 at 6:51 am

    You combined the pseudo-class and class selectors in this rule:

    .topNavigation ul li:last-child a, .topNavigation ul li.last-child a {
    margin-right: 0;
    }
    

    Since IE < 9 doesn’t understand :last-child, it should disregard the entire rule (I’m not sure why it works for you in IE7; it should break in the same way in both IE7 and IE8), even though it can understand and apply the rule for .last-child. Therefore the only margin it can fall back to is your first one.

    Technically the only solution to this is to break it into two rules, one for each selector.

    But I suggest that you just go with adding the HTML classes. Since you’re already doing that to support older browsers, might as well keep it since all browsers support that:

    .topNavigation ul li.first-child a {
    margin-left: 0;
    }
    .topNavigation ul li.last-child a {
    margin-right: 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a css rule like this in my css file: .Island_VerticalMenu:first-child { width:
I have this problem in IE8 that ignores my first stylesheet link. I don't
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have this rule which says use this CSS rule ONLY FOR PRINTING. @media
I have this CSS rule: #panelSeparator .active { background: #fff url(../img/vgrabber.gif) no-repeat center; opacity:
I have this code,everything works fine but .css('color','red') rule is not getting applied.I tried
I have this css: fieldset li { padding-bottom: 0em; } However, it wasn't behaving
i have this CSS code: h1 { font-size:22px; color:#341C12; font-weight:normal; font-style:italic; } .h1color h1{
I have this CSS style that does a rounded corners for div border, but
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid

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.