Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Problem with customizing link color

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #249204
    mw84
    Participant

    Hi,

    My app attempts to use multiple colors for links depending on some business rule.
    For instance, for the following case, I attempted to use RED for the link color. However, since I have a complex inherited CSS file for the entire app, I thought adding the !important at the end would overwrite similar coding for the a (link), but it has effects. How to correct it? Thanks.

    <span>
    <a href="#">Cancer</a>
    </span>

    #249205
    Paulie_D
    Member

    Without seeing the problem it’s hard to help.

    Can you reproduce it Codepen.io?

    #249214
    mw84
    Participant

    My original code was like below:

    <span style="a{color:red !important}"><a href="#" onclick="loadRightDoc('kPoints.cfm?t=','Cancer')">Cancer</a>
    </span>
    
    #249215
    Paulie_D
    Member

    No…that wouldn’t work. you’re appling a style (badly) to the span not the link.

    Your inline style is invalid. You can’t apply an inline style to a child by applying it to a parent.

    You’re trying to apply a CSS Selector inline..and that’s a no-no.

    #249216
    mw84
    Participant

    Ok. I see. So, now, I apply it direct for the link (I know, it’s bad practice for inline CSS but bear with me, solve it first…).

    The following code still did not work, any idea as to why? Thanks.

    &lt;a href="#" onclick="loadRightDoc('kPoints.cfm?t=','Immunotherapy')" style="a{color:#7A30A0}"&gt;Immunotherapy&lt;/a&gt;

    #249217
    Beverleyh
    Participant

    Incorrect syntax again (you were having a similar problem on this thread earlier today https://css-tricks.com/forums/topic/how-to-make-textcontent-in-the-2nd-td-top-aligned/#post-249191 )

    If you’re going to use inline styles, might be worth reading up on it as a refresher http://www.w3schools.com/css/css_howto.asp

    #249218
    mw84
    Participant

    @Beverleyh, yeah, you’re right, embarrassing, I underestimated CSS or was mindless… Thanks.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.