0

It seems that when I add an 'href' tag to my anchor I lose all my css formatting. Is there something special the way css treats links?

Here is the simple css

    .topmenu > ul > li > a:visited,
    .topmenu > ul > li > a:active,
    .topmenu > ul > li > a:hover,
    .topmenu > ul > li > a:link,
    .topmenu > ul > li > a { font-family:Arial; font-size:1.0em; font-weight:bold; color:White; text-decoration:none; }

Here is the html

<div class="topmenu">
    <label>Name of Dept.</label>
    <ul>                    
        <li><a href="http://www.myurl.com">Itinerary</a></li>
        <li><a>Team Members</a></li>
        <li>Fundraising</li>
        <li>Resources</li>
        <li>Dates</li>
    </ul>        
</div>   

The without the href formats properly. The with the href doesn't. I would have thought that the css a:link and a:visited would have covered that scenario. If I add !important to the css, then I get the proper formatting everywhere.

2
  • 4
    Just a note, in IE an anchor tag without an HREF is not recognized as a link. Styling wise it does not get any of the css benefits of an anchor, such as hover, link, visited and active. Commented Aug 25, 2009 at 18:49
  • Ummm, you should try your minimal example. It works. At least in FF3 here. Commented Aug 25, 2009 at 19:00

1 Answer 1

1

The fact that you can add !important to the rule is indicating you have another rule that is taking precedence. Do you have something that is targeting with a[href]?

Try loading up your page in Firebug or Safari's Developer tool and see if another style you have specified is overriding your rule.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.