Establish a color scheme for visited hyperlinks

I have come across several discussions about the :visited pseudo-class not working anymore, especially on modern browsers. Most of these discussions are older posts.

For example, one of them can be found here: Google chrome a:visited background image not working

The post mentions that the color attribute seems to work, but in my testing on Chrome, it does nothing. It works on IE, but loses the styling on the next click.

It must be possible somehow....I mean, Google manages to do it :))

Can anyone suggest any ideas? Maybe I missed something.

Thanks!

EDIT: This is the code snippet I am currently 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 applying the class directly to the Label and experimenting with a:hover, a:visited, but with no success.

This is ASP.Net and C#.

Thank you for your responses.

EDIT: The generated code looks like this:

<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 CSS code (I have removed the class from the Label and replaced it with your CSS): The anchor links in the horizontal menu apply the style, but those within the repeater do not:

a:visited {
    color: purple;
}
a:link {
    color: blue;
}

Answer №2

Use the following CSS code to style anchor tags on modern web browsers:

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

The classes .link, .hover, .active, and .visited are used to specify different colors for links, link hover effects, active link colors, and visited link colors respectively.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm wondering why using display flex with justify-content center and align-items center is not properly centering the elements both horizontally and vertically. Can anyone explain this?

As I delve into the world of JavaScript, I find myself coding simple JS, HTML, and CSS snippets to enhance my learning experience. These exercises help me grasp the concepts well enough to create various JS web elements and projects. My goal is to eventual ...

Tips for maintaining the chat scroll position while typing on mobile devices

Check out this example page: https://codesandbox.io/s/summer-flower-uxw47?file=/index.html:4175-4223 The issue at hand is that when accessing the site from a mobile device and tapping on the input field, the keyboard pops up. This causes the text in the m ...

It is not possible to expand the textarea on mobile devices

I have an HTML textarea in one of my web pages using the HTML5 boilerplate template. The pages are responsive and display correctly on all devices, however, I am encountering an issue with the textarea element not being able to stretch. The resizing patter ...

Could a 1 pixel GIF be the next innovation in measuring tools? BLANK_IMAGE_URL - what mysterious purpose does it serve?

Currently diving into the ExtJs documentation and stumbled upon the BLANK_IMAGE_URL property. According to the docs, it's a link to a 1-pixel transparent GIF that helps with accurate measurements. But how can such a small image be useful for measurin ...

Displaying a specific div in AngularJS

My ng-repeats are structured like this: <div ng-repeat = "car in cars track by car" > <div ng-repeat = "driver in drivers track by driver"> <div> <label> {{driver}} </label> </div> <div> <!-- div 3 ...

Enhance user experience in R Shiny by integrating a text input field with the slider bar for increased usability

When dealing with a range that has a significantly large gap, like 2000, using the built-in sliderInput to make small adjustments can be challenging. I am considering implementing two textInputs to work in conjunction with the sliderBar for more precise ...

Utilizing Bootstrap in a loop iteration

I have a web application that interacts with a MYSQL database and generates a row for each data entry. Within these rows, there is a toggle button that should perform one action when checked and another when unchecked. Currently, the functionality only wo ...

Creating a transparent background in a three.js canvas: a step-by-step guide

I came across a wave particle animation on Codepen (https://codepen.io/kevinsturf/pen/ExLdPZ) that I want to use, but it has a white background. However, when I try to set the body background to red, it doesn't show up once the canvas is rendered. I ...

The button designed to delete the parent container div is ineffective when applied to dynamically generated divs

I'm in the process of developing a JavaScript to-do list app from scratch. Everything is functioning properly except for the button that is supposed to remove items from the list. Here is the HTML snippet: <div class="todolistcontainer"& ...

Ways to acquire ttf files from a third-party domain without encountering CORS issues

I am attempting to obtain a .ttf file from an external website for use in my web application. However, when I try the following code: @font-face { font-family: 'font'; src: url('http://xxx.xyz/resources/tipografias/font.ttf') forma ...

Saving HTML elements within an XML file

I am dealing with a String that has an html format containing various html tags. My goal is to enclose this string within xml tags while preserving the html tags, for example: public class XMLfunctions { public final static Document XMLfromString(Str ...

Utilize jQuery to apply a CSS class to the element that is clicked and inject additional content into a designated div

Here is a link to a page where I am experimenting with creating an interactive choose-your-own-adventure story: My goal is to add the class "disabled" to the element when a user clicks on the word "stairs" and then continue the story. Below is the relevan ...

Yii2: Incorporating an entire UI/Design concept sourced externally from Yii

My colleague and I are collaborating on a website project. He is responsible for frontend UI design, customizations, and everything related to end users. The layouts/themes we are using are based on Bootstrap, with additional elements from the Metronic the ...

The Art of Div Switching: Unveiling the Strategies

I have a question regarding my website. I have been working on it for some time now, but I have encountered a challenge that I am struggling to overcome. After much consideration, I am unsure of the best approach to take. The issue at hand is that I have ...

What is the reason behind Bootstrap's varying column spacing based on the number of columns?

<br> <h6> This particular row/display consists of two elements. It is interesting to note that even with col-md-4, it expands to occupy more than 2/3 of the total width. </h6> <div class="flex-row"> <div class="card-deck"&g ...

Apply a box-shadow to the lower part of the div starting from the center

After much searching, I finally found a preview of what I had in mind. Unfortunately, I couldn't find the right words to describe it. Here is the link to the image for reference: https://i.sstatic.net/t2q27.png Thank you in advance for your help. ...

Using jQuery to collapse nested lists within a hierarchical structure

I'm facing a frustrating issue that seems to stem from my limited knowledge of javascript and jQuery. The problem lies within a list structured using recursion for hierarchy. Here's a snippet of the code: $(function (){ $('#foo').c ...

How can I make a bootstrap container maximize the available viewport space?

I've come across several similar posts, but none seem to address my particular dilemma. My challenge lies in presenting a table at the end of a bootstrap grid: <div class="container-fluid"> <!-- Various rows with different size ...

Developing jpg/png images from .ppt/pptx files with Django

I currently have a PowerPoint file saved on Dropbox at "". My goal is to convert this presentation file into individual slide images (jpg/png..) within my Django template or using a Django def function. Once I have converted the slides, I plan to utilize ...

Sorting two distinct lists in parallel using the jQuery sortable feature

I encountered a unique scenario where I had to separate the data into two distinct lists in an html file. Here is what it looked like: <ul id="first_list"> <li ref="1">The quick brown</li> <li ref="2">My father works</li ...