It is not possible to modify the appearance of visited :before pseudo-elements

After attempting to enhance the appearance of visited links with various effects, I encountered an issue.

Below is the code snippet in question:

It seems that only Opera browser is able to modify the content of the :before pseudo-elements successfully. Other browsers seem to be failing in this aspect. Any insights on what might be causing this discrepancy would be greatly appreciated. Thank you!

Answer №1

The CSS properties that can be applied to visited links include color, background-color, border-*-color, outline-color, and column-rule-color (with some exceptions).

This restriction is in place to prevent security vulnerabilities like history stealing attacks. For more information, refer to this informative article.

Although it may seem like a bug, setting a :before pseudo class for :visited links will be disregarded intentionally, making the links appear as unvisited. This behavior is not an issue but rather a deliberate design choice ;)

Answer №2

In order to protect user privacy, modern browsers have limited the styling options for :visited links. This restriction prevents websites from detecting which sites a user has visited in the past using JavaScript to check the computed styles.

The only properties allowed for styling :visited links are:

  • color
  • background-color
  • border-color (and its variations)
  • outline-color
  • The color components of fill and stroke properties

Even with these limitations, it is not possible to access the computed style values for visited links through JavaScript.

For more information, you can refer to this article here.

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

Why does my marquee tag mysteriously have a bottom margin? Any tips on how to get rid of it?

After creating my website, I noticed that the marquee I added has an unexpected bottom margin even though I didn't specify one. I confirmed it was the marquee causing the issue by placing other tags below it, and the bottom margin persisted. <marqu ...

At a specific media query breakpoint, links are disabled while the rest continue to function without any

Today I encountered a puzzling issue on my website with a responsive layout that utilizes @media queries and breakpoints. At one specific breakpoint (or resolution, as I am still learning the terminology), the links in the navigation bar are inexplicably d ...

Employing conditional statements in conjunction with styled components

Is there a way to style my PaymentBtn with the main styled Button but only apply the hover effect when the isLoading prop is activated, without changing anything else? I want the styling to remain the same except for the hover effect. Basic button export ...

Creating a draggable element in JavaScript using React

I've been attempting to create a draggable div element, but I'm encountering some perplexing behavior. The code I'm using is directly from w3schools and it functions correctly for them, however, in my implementation, the div always shifts to ...

Element is not being overlapped by higher z-index

#navbarContentHamburger { background-image: url(../img/657904-64.png); background-size: contain; z-index: 3; position: fixed; width: 22px; height: 20px; top: 7.7px; left:8px; } .open { width: 4% !important; transiti ...

Responsive flex elements in a single line

I am facing a challenge with five divs that I want to display inline and make them responsive. The issue is that when the window size changes, they end up getting squished together instead of breaking into a new row as desired. I have tried various methods ...

The hidden overflow seems to be inconsistently effective

I've been working on creating some buttons with a rollover state. I have an image inside a div with overflow:hidden to hide the inactive state, but sometimes it doesn't work properly. What's even stranger is that when I inspect the page usi ...

Is there a way to create a gradual fading effect on my images?

Check out the images currently on my portfolio page: .collection-type-gallery #slideshow .slide img:hover { opacity: 1; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease ...

Unresolved Issue: Jquery Modal Fails to Activate on Subsequent Click for Ajax-

When I make an Ajax call, I load HTML into a div. This HTML content contains a jQuery modal that opens when clicked. However, on the first click, the modal opens correctly. On subsequent clicks, I receive the following error in the console: Uncaught Type ...

selection menu and advancement gauge

While working on my code, I have a task where I need to make the progress bar move a specific amount when a name is clicked based on the option's value. <!DOCTYPE html> <html> <head> <title>testinggg</title> &l ...

The webpage contains duplicate ID attribute value "x" that has been identified

In my Angular 7 project, three components (a, b, c) all use an input element with the same id of "x". However, component b has 4 input elements all using the id "x" as well. This poses Accessibility Issues as ids must be unique. The test cases utilize &apo ...

Dynamically linking tabbable tabs is a useful technique that allows for

I have been working on an app that organizes websites into groups displayed as tabs in a tabbable navigator using Twitter Bootstrap. The idea is that each time a new group is added, a new tab should appear. Currently, this is how it looks: The functionali ...

There seems to be a syntax error in the script where an expression was expected but

I have attempted numerous times to solve this issue but have been unsuccessful. Here is the code I have tried: <?php while($crow = mysqli_fetch_assoc($cres)) { echo ' <div class="item" onc ...

Tips for positioning icons inserted using the :before method

Is there a way to center align an icon added using the :before method? Below is the current code snippet: <div class="button submit"> <a class="submit check_car_search" href="#" >Some Text</a> </div> CSS: .button a{ backgr ...

Determine the position of an element in relation to a specific ancestor using JavaScript

Let's consider the following example of HTML code: <div id="site_header_container" class="site_bar_container"> <div id="site_header"> <div id="header_logo_container"> <a class="sliced" id="header_ ...

Deleting content from cells in table for all even td items

This problem has been causing me frustration; I've attempted various methods using jquery and CSS, but to no avail. Essentially, I have the following table structure: <table id="mainTable"> <thead> <tr> <th>Arrival ...

Is there a way to position a pseudoelement behind its parent yet still in front of its grandparent using absolute positioning?

Imagine the following scenario: <div id="one"/> <div id="two"> <div id="three"/> </div> <div id="four"/> I am trying to apply a pseudoelement to three that appears behind it but in front of two (and any other ancestors if ...

The image does not properly scale within the div as it rotates

I am currently attempting to use jQuery to rotate an image, but I am facing an issue. When I rotate the image left or right, a portion of it extends beyond the frame. The image is not resizing based on the CSS properties set as max-height: 100%; max-width: ...

Arranging divs in a row using jQuery sortable technique

Greetings! I have been attempting to achieve horizontal sorting for two divs but have encountered a couple of issues. Firstly, the divs do not align correctly upon initial page load and secondly, while they can be dragged around, the sortable functionality ...

Stretchable navigation cell

I am working on a navigation bar called "nav" that consists of a "ul" and "li". I have specified the display property for the "ul" as table and for the "li" as table-cell. Setting the "ul" to take up the full width of the wrapper ensures proper alignment. ...