Search code examples
htmlcssanchor

HTML Anchor, Disable Style


I have some html anchor link code, and unlike the rest of document I want it to look like it is not a link.

Is there a simple way to disable the style change caused by wrapping text in a anchor tag without having to brute force it to be the same (ie, if I change the body font style I don't have to also change some other :link stuff).


Solution

  • Setting color to black and text-decoration to explicitly none is a little more aggressive than worked for me.

    I was looking for the CSS of the anchors to be "benign" and just blend into the existing CSS. Here's what I went with:

    a.nostyle:link {
        text-decoration: inherit;
        color: inherit;
        cursor: auto;
    }
    
    a.nostyle:visited {
        text-decoration: inherit;
        color: inherit;
        cursor: auto;
    }
    

    Then I just added the CSS nostyle class to the anchors that I wanted to be unformatted.