什么是默认的 HTML/CSS 链接颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4774022/
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 06:18:52  来源:igfitidea点击:

What's default HTML/CSS link color?

htmlcss

提问by Bill

I need its code representation, like #FFFFFF.

我需要它的代码表示,比如#FFFFFF.

回答by BoltClock

As of HTML5, the foreground colors of hyperlinks, among other things, are on track for standardization in the form of guidelines for expected default rendering behavior. In particular, taken from the section Phrasing content, the recommended default colors for unvisited and visited hyperlinks are the following:

从 HTML5 开始,超链接的前景色以及其他内容正在以预期默认呈现行为指南形式进行标准化。特别是,从短语内容部分中,未访问和访问过的超链接的推荐默认颜色如下:

:link { color: #0000EE; }
:visited { color: #551A8B; }

Notice that there is no recommended default for active hyperlinks (:link:active, :visited:active), however.

请注意,活动超链接 ( :link:active, :visited:active)没有推荐的默认值。

You can use these default colors and reasonablyexpect them to work. But keep in mind that a browser is free to ignore any or all of these guidelines, as it is never requiredto follow them. It is, however, recommendedfor a consistent user experience across browsers (which is how "expected" is defined in this context), so chances arethat these colors will correspond to the defaults for most browsers. At worst, they still serve as reasonable approximationsof the actual values.

您可以使用这些默认颜色并合理地期望它们起作用。但请记住,浏览器可以随意忽略任何或所有这些准则,因为它从不需要遵循这些准则。它,但是,建议对跨浏览器一致的用户体验(这是怎样的“预期”在此背景下定义),所以机会是这些颜色将对应于默认为大多数的浏览器。在最坏的情况下,它们仍然是实际值的合理近似值

In particular, the default unvisited and visited link colors in the latest versions of Firefox and Chrome are consistent with the above guidelines, but recent versions of IE report different values: unvisited links are rgb(0, 102, 204), or #0066CC, and visited links are rgb(128, 0, 128), or #800080. Older versions of Firefox (and possibly Safari/Chrome) had different defaults as well. Those are older versions, however; the main outlier today that I am aware of is IE. No word yet on whether this will change in Project Spartan — currently it still reflects the same values as the latest version of IE.

尤其是最新版本的 Firefox 和 Chrome 中默认的未访问和访问过的链接颜色与上述准则一致,但最近版本的 IE 报告不同的值:未访问的链接是rgb(0, 102, 204)、 或#0066CC,访问过的链接是rgb(128, 0, 128)、 或#800080。旧版本的 Firefox(可能还有 Safari/Chrome)也有不同的默认值。然而,这些是旧版本;今天我所知道的主要异常值是 IE。目前还没有关于这是否会在 Project Spartan 中改变的消息——目前它仍然反映了与最新版本的 IE 相同的值。

If you are looking for a standardized color scheme that is usedby all browsers rather than suggested by HTML5, then there isn't one. Neither is there a way to revert to a browser's default value for a particular property on a particular element using pure CSS. You will have to either use the colors suggested by HTML5, or devise your own color scheme and use that instead. Either of these options will take precedence over a browser's defaults, regardless of browser.

如果您正在寻找一种适用于所有浏览器而不是 HTML5 建议的标准化配色方案,那么就没有了。也没有办法使用纯 CSS 将特定元素上的特定属性恢复为浏览器的默认值。您将不得不使用 HTML5 建议的颜色,或者设计您自己的配色方案并使用它。无论浏览器如何,这些选项中的任何一个都将优先于浏览器的默认设置。

If in doubt, you can always use the about:blanktechnique I described before to sniff out the default colors, as it remains applicable today. You can use this to sniff the active link color in all browsers, for example; in the latest version of Firefox (29 as of this update), it's rgb(238, 0, 0), or #EE0000.

如果有疑问,您可以随时使用about:blank我之前描述的技术来嗅探默认颜色,因为它今天仍然适用。例如,您可以使用它来嗅探所有浏览器中的活动链接颜色;在最新版本的 Firefox 中(截至本次更新为 29),它是rgb(238, 0, 0), 或#EE0000

回答by Caspar Kleijne

  • standard link - #0000FF //blue
  • visited link - #800080 //purple
  • active link - #FF0000 //red
  • 标准链接 - #0000FF //蓝色
  • 访问过的链接 - #800080 //紫色
  • 活动链接 - #FF0000 //红色

that was a standard but heavily differs per browser now. (since Nielsen gave it up ;)

这是一个标准,但现在每个浏览器都大不相同。(因为尼尔森放弃了;)

回答by Neil

The default colours in Gecko, assuming the user hasn't changed their preferences, are:

假设用户没有改变他们的偏好,Gecko 中的默认颜色是:

  • standard link: #0000EE(blue)
  • visited link: #551A8B(purple)
  • active link: #EE0000(red)
  • 标准链接:(#0000EE蓝色)
  • 访问链接:(#551A8B紫色)
  • 活动链接:(#EE0000红色)

Source

来源

Gecko also provides names for the user's colours; they are -moz-hyperlinktext-moz-visitedhyperlinktextand -moz-activehyperlinktextand they also provide -moz-nativehyperlinktextwhich is the system link colour.

Gecko 还为用户的颜色提供名称;它们是-moz-hyperlinktext-moz-visitedhyperlinktext并且-moz-activehyperlinktext它们还提供-moz-nativehyperlinktext哪个是系统链接颜色。

回答by phihag

According to the official default HTML stylesheet, there is no defined default link color. However, you can find out the default your browser uses by either taking a screenshot and using the pipette tool in any decent graphic editor or using the developer tools of your browser (select an aelement, look for computed values>color).

根据官方默认的 HTML 样式表,没有定义默认链接颜色。但是,您可以通过截取屏幕截图并在任何合适的图形编辑器中使用移液器工具或使用浏览器的开发人员工具(选择一个a元素,查找computed values>color)来找出浏览器使用的默认值。

回答by grandia

I am used to Chrome's color so the blue color in Chrome for link is #007bff

我习惯了 Chrome 的颜色,所以 Chrome 中的蓝色链接是 #007bff

回答by Russell Pekala

For me, on Chrome (updated June 2018) the color for an unvisited link is #2779F6. You can always get this by zooming in really close, taking a screenshot, and visiting a website like html-color-codes.info that will convert a screenshot to a color code.

对我来说,在 Chrome(2018 年 6 月更新)上,未访问链接的颜色是 #2779F6。你总是可以通过放大非常近,截取屏幕截图并访问像 html-color-codes.info 这样的网站来获得它,该网站会将屏幕截图转换为颜色代码。

回答by Femaref

Entirely depends on the website you are visiting, and in absence of an overwrite on the website, on the browser. There is no standard for that.

完全取决于您正在访问的网站,并且在网站上没有覆盖的情况下,在浏览器上。没有标准。

回答by Dominik

In CSS you can use the color string currentColorinside a link to eg make the border the same color as your default link color:

在 CSS 中,您可以使用currentColor链接内的颜色字符串来使边框的颜色与默认链接颜色相同:

.example {
    border: 1px solid currentColor;
}

回答by jeffszusz

The best way to get a browser's default styling on something is to not style the element at all in the first place.

获得浏览器默认样式的最好方法是一开始就根本不设置元素的样式。

回答by R. Kumar

Default html color code like this:

像这样的默认 html 颜色代码:

Red      #FF0000  rgb(255, 0, 0)
Maroon   #800000  rgb(128, 0, 0)
Yellow   #FFFF00  rgb(255, 255, 0)
Olive    #808000  rgb(128, 128, 0)
Blue     #0000FF  rgb(0, 0, 255)
Navy     #000080  rgb(0, 0, 128)
Fuchsia  #FF00FF  rgb(255, 0, 255)
Purple   #800080  rgb(128, 0, 128)