SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using styles in <a hrefs .....

    Does anyone have problems when applying font styles through a <a href,

    I get this thing where it sometimes works and sometimes doesn't with no apparant pattern.

    Should i always use a divs or spans to add class's for best practice or what?

    are you not allowed to put in class's into <a hrefs in this way or something?

  2. #2
    SitePoint Enthusiast Unleashed Ideas's Avatar
    Join Date
    Nov 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do this

    <a href="yourlink.asp" class="bright">this is your link</a>

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea mate thats the way i do it and sometimes it works sometimes it doesn't!!

    does anyone else get this problem!!

    I generally go for the <span class="name"><a href ......

    but i just wondered if i was doing something fundementally wrong or not?

  4. #4
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to be careful that you are not declaring contradictory rules in your stylesheet(s), and be aware that pseudo-classes (e.g. :hover) will be applied in preference of element-only selectors (e.g. "a { color: red; }").

  5. #5
    SitePoint Zealot MrDiaz's Avatar
    Join Date
    Dec 2005
    Location
    Ontario, Canada
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    also you need to be aware of the different states the <a> is at.

    Link, visited, hover, active.

    Maybe you only have set up on your stylesheet the style for the link or other, just make sure you have a style for each state.
    My Website:
    www.planetdiaz.com

  6. #6
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    Toronto
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, continue with what mrdiaz said, the default a{}; only gives styling to the link state.

  7. #7
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea guys thanks for the help but i dont think its any of the above. Im aware of the link states and its more a matter of the style doesn't work in a

    <a href class=".. (Not Work)

    but if i was to move the <a href... link in between a <span> containing the class then it would work. So i assume that would suggest that it's not the styles that are the problem here?

    <span class="style"><a href ... (Works)

    It happened to me again yesterday. I had this link with the correct styles on the dev site and the staging sites im working on and on the live site it lost the styling on the link. I checked and all the css and the code on the page was uploaded and up to date so i can't understand what is going on. It just seems odd and random so i added a span around the link with the class as i always do as a work around and it works?

    But i want to find out why it happens, or if anyone else gets this!! Am i doing something wrong?

  8. #8
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's likely to be a specifity and/or inheritance issue which we can't pinpoint from such a limited view of your code.

  9. #9
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks, have you got a link where i can read up on that?

    It seems a little odd how it works in 2 identitical situations and not in the third.

    Stylesheetwise they all run the same ones! 100%

    Code wise im pretty sure too.

  10. #10
    SitePoint Enthusiast Unleashed Ideas's Avatar
    Join Date
    Nov 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    give us a link!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •