Html 如何删除html超链接'a'标签的默认链接颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6722467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 09:36:22  来源:igfitidea点击:

How to remove the default link color of the html hyperlink 'a' tag?

htmlcssanchorhtml-helper

提问by Rafiu

The default link color is blue. How to remove the default link color of the html hyperlink tag <a>?

默认链接颜色为蓝色。如何去除html超链接标签的默认链接颜色<a>

回答by Quentin

The inherit value:

继承值

a { color: inherit; } 

… will cause the element to take on the colour of its parent (which is what I think you are looking for).

... 将导致元素呈现其父元素的颜色(我认为您正在寻找)。

回答by kleinohad

you can do some thing like this:

你可以做这样的事情:

a {
    color: #0060B6;
    text-decoration: none;
}

a:hover 
{
     color:#00A0C6; 
     text-decoration:none; 
     cursor:pointer;  
}

if text-decoration doesn't work then include text-decoration: none !important;

如果 text-decoration 不起作用,则包含 text-decoration: none !important;

回答by Kaan Soral

.cancela,.cancela:link,.cancela:visited,.cancela:hover,.cancela:focus,.cancela:active{
    color: inherit;
    text-decoration: none;
}

I felt it necessary to post the above class definition, many of the answers on SO miss some of the states

我觉得有必要发布上面的类定义,SO上的许多答案都错过了一些状态

回答by GURU PRASAD

If you don't want to see the underline and default color which is provided by the browser, you can keep the following code in the top of your main.css file. If you need different color and decoration styling you can easily override the defaults using the below code snippet.

如果您不想看到浏览器提供的下划线和默认颜色,您可以将以下代码保留在 main.css 文件的顶部。如果您需要不同的颜色和装饰样式,您可以使用以下代码片段轻松覆盖默认值。

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

回答by gerd hübner

This is also possible:

这也是可能的:

        a {
            all: unset;
        }

unset: This keyword indicates to change all the properties applying to the element or the element's parent to their parent value if they are inheritable or to their initial value if not. unicode-bidi and direction values are not affected.

unset:该关键字表示将应用于元素或元素的父元素的所有属性,如果它们是可继承的,则更改为其父值,否则更改为它们的初始值。unicode-bidi 和方向值不受影响。

Source: Mozilla description of all

来源:Mozilla 对所有的描述

回答by Saad Imran.

You have to use CSS. Here's an example of changing the default link color, when the link is just sitting there, when it's being hovered and when it's an active link.

你必须使用CSS. 这是更改默认链接颜色的示例,当链接位于那里时,当它悬停时以及当它是活动链接时。

a:link {
  color: red;
}

a:hover {
  color: blue;
}

a:active {
  color: green;
}
<a href='http://google.com'>Google</a>

回答by ArifMustafa

Simply add this in CSS,

只需将其添加到CSS,

a {
    color: inherit;
    text-decoration: none;
}

that's it, done.

就这样,大功告成。

回答by knittl

You can use System Color (18.2)values, introduced with CSS 2.0, but deprecated in CSS 3.

您可以使用系统颜色 (18.2)值,该值在 CSS 2.0 中引入,但在 CSS 3 中已弃用

a:link, a:hover, a:active { color: WindowText; }

That way your anchor links will have the same color as normal document text on this system.

这样,您的锚链接将与此系统上的普通文档文本具有相同的颜色。

回答by sounish nath

a:link{color:inherit;}

this is the simple one line can do all stuffs for you <3

这是简单的一行可以为你做所有的事情 <3

回答by Sumeet Rohra

This will work

这将工作

    a:hover, a:focus, a:active {
        outline: none;
    }

What this does is removes the outline for all the three pseudo-classes.

这样做是删除所有三个伪类的轮廓。