:visited

:visited

The :visited CSS pseudo-class lets you select only links that have been visited. This style may be overridden by any other link-related pseudo-classes, that is :link, :hover, and :active, appearing in subsequent rules. In order to style appropriately links, you need to put the :visited rule after the :link rule but before the other ones, defined in the LVHA-order: :link:visited:hover:active.

Note: For privacy reasons, browsers strictly limit the styles you can apply using an element selected by this pseudo-class: only color, background-color, border-color, border-bottom-color, border-left-color, border-right-color, border-top-color, outline-color, column-rule-color, fill and stroke- Note also that the alpha component will be ignored: the alpha component of the not-visited rule is used instead (except when the opacity is 0, in that case the whole color is ignored, and the one of the not-visited rule is used)-

Though the color can be changed, the method getComputedStyle will lie and always give back the value of the non-visited color-

For more information on the limitations and the motivation for them, see Privacy and the :visited selector.

Syntax

:visited { style properties }

Examples

a:visited { color: #4b2f89; }
a:visited { background-color: white } 

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of ':visited' in that specification.
Living Standard
Selectors Level 4
The definition of ':visited' in that specification.
Working Draft No change.
Selectors Level 3
The definition of ':visited' in that specification.
Recommendation No change.
CSS Level 2 (Revision 1)
The definition of ':visited' in that specification.
Recommendation Lift the restriction to only apply it for <a> element. Let browsers restricts its behavior for privacy reasons.
CSS Level 1
The definition of ':visited' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) 1.0 (1.7 or earlier) 3.5 3.5 1.0
Restrictions in CSS properties allowed in a statement using :visited 6 (Yes) 4.0 (2.0) 8 (or earlier) ? 5.0
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 4.4 (Yes) 1.0 (1.0) 11 37 9.3

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/:visited

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部