Home > Web Front-end > CSS Tutorial > Why Are My Styled Visited Links Not Working in Some Browsers?

Why Are My Styled Visited Links Not Working in Some Browsers?

Linda Hamilton
Release: 2024-12-02 05:34:09
Original
593 people have browsed it

Why Are My Styled Visited Links Not Working in Some Browsers?

Why Doesn't This CSS Style for :visited Links Work in Specific Browsers?

The following HTML and CSS code seems to exhibit an issue with styling visited links in Internet Explorer and Chrome:

<html>
    <head>
        <style>
            A {font-weight: bold; color:black;}
            A:visited {font-weight: normal; color: black; }
            .Empty {font-weight: bold; color: black; }
        </style>
    </head>

    <body>
        <a href="http://mysite">click me</a>
    </body>
</html>
Copy after login

Despite applying the :visited pseudoclass, the clicked link remains bold instead of returning to normal weight. This behavior also occurs with Firefox 4, IE9, and Chrome.

Security Considerations and Workarounds

The functionality of the :visited pseudoclass has been restricted in modern browsers to prevent potential CSS exploits. These browsers implement specific measures to protect against such vulnerabilities:

  • getComputedStyle() returns values for visited links as if they were unvisited.
  • Sibling selectors (e.g., :visited span) cause adjacent elements to be styled as unvisited.
  • Nested link elements may render as unvisited in certain scenarios.

Unfortunately, there is no workaround for this security measure in browsers that have implemented these restrictions. Changing the accessibility settings to ignore web colors, as mentioned in the original question, would not resolve the issue.

The above is the detailed content of Why Are My Styled Visited Links Not Working in Some Browsers?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template