0

I have found many posts on how visited doesn't work anymore (most of them pretty old posts) on modern browsers.

One of them: Google chrome a:visited background image not working

This one is saying that the color attribute is though working. Well, not for me, I am testing on Chrome which does nothing, IE does but on the next click it looses it.

It must be possible somehow....I mean, Google does it :))

Can someone please bring any ideas? maybe I missed something.

Thanks!

EDIT: This is the code I am using:

<asp:Repeater ID="rptArrival" runat="server">
   <ItemTemplate>
      <div class="left">
        <a id="aCityTo" runat="server" OnServerClick="lnkLink_OnCommand" cities='<%# Eval("CityCodeFrom")+"|"+ Eval("CityCodeTo") %>'  >
          <asp:Label runat="server" ID="Label1" Text='<%# Eval("CityNameTo") %>' CssClass="linkButtonBold"></asp:Label>
        </a>
      </div>
   </ItemTemplate>
</asp:Repeater>

.linkButtonBold
{
    font-family: Arial, Helvetica, sans-serif;
    font-style: normal;
    font-size: 12px;
    font-weight: bold;
    color: #829094;
    text-decoration: none;
    cursor: pointer;
}

.linkButtonBold:hover
{
    text-decoration: underline;
}

.linkButtonBold:visited {
    color: red;
}

I have also tried without the class on the Label and with a:hover, a:visited and also nothing.

It is ASP.Net and C#.

Thanks for your replies.

EDIT: The generated code:

<div class="left">
    <input type="hidden" name="ctl00$ContentPlaceHolder1$rptLowCost$ctl00$rptLowCostDepartures$ctl00$rptArrival$ctl00$hfCityCodeTo" id="ctl00_ContentPlaceHolder1_rptLowCost_ctl00_rptLowCostDepartures_ctl00_rptArrival_ctl00_hfCityCodeTo" value="AMS">                                                               
    <a id="ctl00_ContentPlaceHolder1_rptLowCost_ctl00_rptLowCostDepartures_ctl00_rptArrival_ctl00_aCityTo" cities="CLJ|AMS" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$rptLowCost$ctl00$rptLowCostDepartures$ctl00$rptArrival$ctl00$aCityTo','')">
   <span id="ctl00_ContentPlaceHolder1_rptLowCost_ctl00_rptLowCostDepartures_ctl00_rptArrival_ctl00_Label1">Amsterdam</span>
   </a>
</div>

and the class (I have taken off the class of the Label and replaced it with your css). The anchors in the horizontal menu are taking the style, but these ones, from the repeater don't:

a:visited {
color: purple;
}
a:link {
color: blue;
}
Community
  • 1
  • 1
bokkie
  • 1,477
  • 4
  • 21
  • 40

2 Answers2

6

Really? Are you talking about CSS pseudo-classes? These are not obsolete, can we see your code?

a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red;}
a:active {color: yellow;}

http://www.w3.org/TR/CSS2/selector.html#link-pseudo-classes

http://css-tricks.com/snippets/css/link-pseudo-classes-in-order/

https://developer.mozilla.org/en-US/docs/CSS/Pseudo-classes

Mike Sav
  • 14,805
  • 31
  • 98
  • 143
  • try replacing CssClass="linkButtonBold" use class="linkButtonBold" on the the a tag. – Mike Sav Jan 21 '13 at 15:57
  • The code CssClass="linkButtonBold" is on the not the . – Mike Sav Jan 22 '13 at 09:42
  • nope, that didn't work either. also did the a:link....thing that you wrote and no class on the a or label, and still nothing. But I did a workaround for it. in code behind, on click, I change the class of the a: `((HtmlAnchor) sender).Attributes["class"] = "visitedLinkButtonBold"; ` – bokkie Jan 22 '13 at 12:37
1

The following CSS should be able to style anchor tags on all modern browsers:

a:link {
    color:#222;
}
a:hover {
    color:#000;
}
a:active {
    color:#000;
}
a:visited {
    color:#444;
}

.link specifies the link color, .hover will change the color of the link when moused over, .active will specify the active link color, and .visited will specify the color of the link after it has been clicked.

Charles
  • 4,372
  • 9
  • 41
  • 80