HTML and CSS Reference
In-Depth Information
Visited links and privacy
For well over a decade, it was possible to style visited links with any CSS properties
available, just as you could unvisited links. However, in the mid-2000s several people
demonstrated that one could use visual styling and simple DOM scripting to determine
if a user had visited a given page. For example, given the rule :visited {font-weight:
bold;} a script could find all of the boldfaced links and tell the user which of those sites
they'd visited—or, worse still, report those sites back to a server. A similar, non-scripted
tactic uses background images to achieve the same result.
While this might not seem terribly serious to you, it can be utterly devastating for a
web user in a country where one can be jailed for visiting certain sites—opposition
parties, unsanctioned religious organizations, “immoral” or “corrupting” sites, and so
on. Thus, two steps were taken.
The first step is that only color-related properties can be applied to visited links: color ,
background-color , column-rule-color , outline-color , border-color , and the individ-
ual-side border color properties (e.g., border-top-color ). Attempts to apply any other
property to a visited link will be ignored. Furthermore, any styles defined for :link will
be applied to visited links as well as unvisited links, which effectively makes :link “style
any hyperlink,” instead of “style any unvisited hyperlink.”
The second step is that if a visited link has its styles queried via the DOM, the resulting
value will be as if the link were not visited. Thus, if you've defined visited links to be
purple rather than unvisited links' blue, even though the link will appear purple
onscreen, a DOM query of its color will return the blue value, not the purple.
As of mid-2012, this behavior is present throughout all browsing modes, not just “pri-
vate browsing” modes. It is difficult to know how the handling of visited-link styles will
change, if indeed it changes at all. It may be restricted to private browsing at some point.
It is even possible that :visited will be dropped entirely. You should definitely treat
visited-link styling with caution, and absolutely avoid a reliance on any particular styl-
ing of visited links.
User action pseudo-classes
CSS defines a few pseudo-classes that can change a document's appearance based on
actions taken by the user. These dynamic pseudo-classes have traditionally been used
to style hyperlinks, but the possibilities are much wider. Table 1-3 describes these
pseudo-classes.
Table 1-3. User action pseudo-classes
Name
Description
:focus
Refers to any element that currently has the input focus—i.e., can accept keyboard input or be
activated in some way.
:hover
Refers to any element over which the mouse pointer is placed—e.g., a hyperlink over which
the mouse pointer is hovering.
 
Search WWH ::




Custom Search