Why is link underline appearing after clicking the link?

后端 未结 4 1135
执念已碎
执念已碎 2020-12-28 14:01

I have an anchor tag styled with text-decoration: none.

This has removed the underline from my links, which is what I want.

However after the l

4条回答
  •  北海茫月
    2020-12-28 14:57

    That is because the default CSS values for links are declared by different browsers. A link has 4 official states.

    • Normal
    • Hover
    • Active (On mouseclick)
    • Visited
    • (Focus)

    In CSS you can declare the style for each of these. If you want the link not to display the text-decoration in these states:

    a, a:hover, a:active, a:visited, a:focus {
        text-decoration:none;
    }
    

    Answer to your comment

    Yes, you can replace the a with a classname. For instance, you have a link with the class 'myLink'.

    You can make the CSS:

    .myLink, .myLink:hover, .myLink:active, .myLink:visited, .myLink:focus {
        text-decoration:none;
    }
    

提交回复
热议问题