On one webpage, IE 11 is correctly styling certain visited hyperlinks while failing to do so for others

Although I acknowledge that others have asked similar questions, none seem to address the exact issue I am facing, nor do they offer practical solutions or clear explanations.

Issue

I'm encountering a problem where some visited hyperlinks in IE 11 follow my :visited CSS rules while others do not. These links are all on the same page.

The hyperlinks correctly adhere to CSS :visited when leading to external websites, but fail to do so when pointing back to pages within my application, specifically when accessed through IIS 8.5 in IE 11. Interestingly, there are no issues when working locally with links directed to localhost on Visual Studio 2017’s default web server.

This behavior is unique to IE 11 and affects only hyperlinks to pages served by our IIS 8.5 web server. It seems that IE struggles to recognize these pages in its browsing history.

Speculation

My suspicion is that this could be related to how different web servers serve content, particularly in terms of HTTP response headers (refer to the 4th paragraph under Conclusion).

Application Code

The following code snippet is from my application. The hyperlinks should display in red once visited, which works fine except for the mentioned scenario.

ASP.NET

<asp:GridView runat="server" ID="resultsGridView" CssClass="results-grid">
    <Columns>
        <asp:HyperLinkField 
            HeaderText="Item #"
            DataNavigateUrlFormatString="~/ItemDetails.aspx?id={0}"
            DataNavigateUrlFields="ItemId" 
            DataTextField="ItemId" 
            ItemStyle-CssClass="item-number">
        </asp:HyperLinkField>
        <asp:BoundField>...</asp:BoundField>
    </Columns>
    <AlternatingRowStyle>...</AlternatingRowStyle>
</asp:GridView>

CSS

.results-grid .item-number {
    font-weight: bold;
    white-space: nowrap;
}

.results-grid .item-number a:visited {
    color: red;
}

I went ahead and created a test page with hardcoded links, where three go to external sites and two replicate the IIS-served links from the grid view.

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            a:visited {
                color: red;
            }
        </style>
    </head>
    <body>
        <a href="https://www.w3schools.com">W3Schools Home</a><br/>
        <a href="https://www.w3schools.com/html/">W3Schools HTML Tutorial</a><br/>
        <a href="https://www.w3schools.com/css/">W3Schools CSS Tutorial</a><br/>
        <a href="https://example.com/ItemDetails.aspx?id=201725">201725</a><br/>
        <a href="https://example.com/ItemDetails.aspx?id=201774">201774</a>
    </body>
</html>

After testing each link, the external site links showed up as red (as expected), while the application links did not (only in IE 11).

(When viewed in Edge, none of the links remained red, but let's focus on IE for now.)

Conclusion

I am unable to pinpoint why IE fails to honor :visited for certain links on the same page while doing so for others.

The issue is not related to using https, as all links in my test page are https.

It also doesn't depend on whether the visited pages appear in the browser history - all link URLs show up in history.

The browser caching setting does not seem to affect this behavior. Despite this, it's worth noting that IIS appends Cache-Control: private to every HTTP response, although local browser caching should remain unaffected. This peculiar behavior remains unexplained.

To reiterate, :visited works flawlessly in other browsers and even in IE for external sites and local links. The anomaly persists exclusively with links to the app hosted on IIS.

If anyone can provide insight into this phenomenon and help me resolve it, I would greatly appreciate it!

Answer №1

iframe and eliminating the target attribute, I found that IE 11 finally recognized the :visited pseudo-class when the links were accessed within the frame and the page was subsequently refreshed.

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

Tips for aligning a div within a flexbox to the bottom position

I'm having trouble aligning the div at the bottom of the flex box. I attempted to use align-content: flex-end; but it didn't work. Is there a way to keep the <.div class="parameters"> at the bottom of the row? Especially when the ...

JavaScript drag functionality is jerky on iPads, not seamless

I am currently attempting to implement a feature where I can drag a div (#drag) within its parent container (#container) using only pure JavaScript. This functionality is specifically required to work on iPad devices only. After writing a script that func ...

What causes the difference in behavior between Firefox and Chrome when it comes to multiple column rendering and the use of overflow

Recently, I came across an interesting issue in Firefox related to lists inside a div with columns:2 set. In Firefox, when overflow:hidden is applied to the list, it stops rendering in 2 columns. However, in Chrome, the list continues to render in 2 colum ...

Stylesheet for a React component

Why is the CSS code in my React component file not working even though I have imported it? import React from 'react'; import { Carousel } from 'react-bootstrap'; import './Banner'; ...

Issues with Internet Explorer causing headaches with CSS :first-child selector malfunctioning, experiencing strange behavior when utilizing Google Web Fonts

Having some trouble with the layout of a website, particularly in IE. The issue can be observed at . When comparing the page in IE to Firefox, there are noticeable differences. Firstly, the top module on the right side is not displaying correctly in IE. I ...

Column that adjusts to different screen sizes

In the realm of responsive web design, what methods are suggested to achieve the specified CSS display? My main requirement is to have a maximum of three columns. The content should be divided evenly among these three columns. I prefer using SCSS and wel ...

When I access the website through the LinkedIn app, my CSS styles are getting jumbled up

Is there a way to resolve the problem I'm facing with CSS when accessing the site through the LinkedIn app on iPhone? The issues don't occur on Android. If anyone has a solution, please share. Thank you :) Click Here ...

The difference in percentage padding rendering is specific to Firefox only

In my current project, I have created various responsive boxes for displaying news articles on the website. Everything seems to be functioning well except for the news items within the slider at the top of the main content. Surprisingly, they are displayin ...

The "Splash Screen Div" page displayed during transitions and page loading

Creating a "Splash Screen Div" for a loading page involves waiting until everything is loaded and then hiding or moving the div off screen. Below is an example: index.html <div id="loading-Div"> <div id="bear-Logo"> < ...

Change the CSS property to override the text-overflow with ellipsis

In my specific scenario, I need to override the default ellipsis behavior that adds '...' to text when using 'text-overflow: ellipsis', and instead use two stars **. Is there a way to achieve this using only Pure CSS? It is important t ...

The process of eliminating body padding in Nuxt.js

I'm considering building a website using Nuxt.js because I've heard it's both cool and user-friendly. While I do have some knowledge of vue.js, I'm stuck on a particular issue: How can I remove the padding from the body? I understand ...

Prior to stacking the divs, separate the line within the div

In the process of creating a responsive navbar with Bootstrap, I encountered an issue. When resizing the window to a smaller size, the collapse icon shifts from the top right position below my "logo". Here is how the site appears on a regular screen: http ...

The color of the SVG is not visible in the PNG rendition

I have applied a style to an svg image and successfully changed the fill color using a random colors function in JavaScript. However, when I convert the svg to a png format after making these color changes, the PNG file retains the original colors instead ...

Assign a background image to a button using an element that is already present on the page

Is there a way to set the background-image of a button without using an image URL? I am hoping to use an element already in the DOM as the background-image to avoid fetching it again when the button is clicked. For example, caching a loading gif within the ...

How do I change the class of an element using $this?

Please review the code below: $(".nwe-cl-icontext").click(function () { $(this).parent().toggleClass("nwe-active"); }) .nwe-cl-c.nwe-active { background: red; } .nwe-cl-c { background: green; } <scrip ...

Creating a text shadow effect with text that has a transparent color

I am attempting to replicate the design shown below using the CSS text-shadow property, but I keep getting a solid color outcome. I have tried using an rgba value of 255,0,0,0.0 for the font-color and text-shadow like this: text-shadow: -1px -1px 0 #0 ...

The performance of the Splinter fill function seems to be sluggish when using the IE Webdriver

After following a tutorial on using the Splinter framework with Internet Explorer, I managed to make it work. However, there seems to be an issue with the speed of filling in the search field - it's incredibly slow compared to using Chrome or Firefox. ...

looping through the elements in a collection using a for-in loop

Issue with IE 11 Console Chrome Console Behavior When changing the word 'item' to 'anotherItem' in the loop like so: var obj = { id1: 'item 1', id2: 'item 2', id3: 'item 3' }; for (anothe ...

Label text will not be wrapped in front of the label (bootstrap)

I'm struggling with some css coding. I want the text to wrap so the label is positioned on the middle right of the box, similar to this example: . However, currently it looks like this: http://jsfiddle.net/yuvemL1z/ and the label ends up being pushed ...

Uninterrupted movement within a picture carousel

Seeking a way to create a smooth transition in an image slider with sliding dividers using continuous switching when clicking previous/next buttons. Currently, the dividers replace each other from far positions. Any ideas on achieving a seamless single mov ...