Closed Bug 767173 Opened 12 years ago Closed 12 years ago

:visited does not take "background-color" CSS in account (docs say opposite statement).

Categories

(Core :: CSS Parsing and Computation, defect)

All
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 765448

People

(Reporter: gavenkoa, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.4) Gecko/20100101 Firefox/10.0.4 Iceweasel/10.0.4
Build ID: 20120517130437

Steps to reproduce:

I make simple HTML page:

<html>
<head>
   <style type="text/css">
    :link, :visited { outline: 1px dotted !important }
    :link { outline-color: blue !important }
    :visited {
     outline-color: orange !important;
     color: yellow !important;
     background-color: green !important; }
   </style>
</head>
<body>
    <a href="http://brain-break.blogspot.com/">link to blog</a>
</body>
</html>

Open it in Firefox and visit links, then back to original page.


Actual results:

As say

   https://developer.mozilla.org/en/CSS/Privacy_and_the_:visited_selector

outline and color is work (I get yellow link text with orange dotted outline).


Expected results:

But background still white... when must be green...
Depends on: 147777
Component: Untriaged → Style System (CSS)
Product: Firefox → Core
QA Contact: untriaged → style-system
Hardware: x86 → All
Version: 10 Branch → Trunk
The docs are just wrong.  Please read http://dbaron.org/mozilla/visited-privacy for complete documentation on the behavior.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Oh, actually the docs do say this:

  In addition, even for the properties you can set for visited links, you won't be able to
  change the transparency between unvisited and visited links

which you are: your unvisited background is transparent.
Yup, here's a testcase demonstrating correct behavior (with a background-color specified for both visited and un-visited style)
The default background color for everything is "transparent", and :visited styles are not allowed to change the *transparency* of a color, because that can cause a measurable difference in how long it takes to draw the page.

Therefore, if you want :visited to change the background color, you must set the background color of *un*visited links to something other than "transparent".  For example, your test case's styles work as you desire if you add 

    :link { background-color: white; }

or even if you add:

    :link { background-color: rgba(255,0,0,.5) }

(In the latter case, the color that gets painted is not "green" but "rgba(0,128,0,.5)".)
(Whee, personal record for size of mid-air collision.)
BTW, that's what bug 147777 comment 288 says.
I will add some clarifying text to the docs because it's easy to miss that an unspecified background-color defaults to transparent.
@j.j What docs you update??

I edit page

  https://developer.mozilla.org/en/CSS/Privacy_and_the_:visited_selector

and add working example. They cover all hard cases with CSS for :visited.

Anyone can improve page as my English is pure...
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: