Search code examples
htmlcsssvgsafarivisited

Safari not showing visited color for svg icon that is inside an anchor tag


Safari is not showing visited color for svg icon that is inside an anchor tag.

The link text shows the visited color, but the svg icon does not. When I inspect the svg in safari, it shows that it should have the visited color, inherited from the link:

Visited color seems to be on

If I check the computed styles from the inspector, it also shows it should have the visited color:

computed styles

Is it possible to get Safari to show the visited color for the svg icon?

Safari version: Version 14.1.1 (16611.2.7.1.4)


Solution

  • Was able to solve this. The icon color was set with fill=currentColor. And for some reason Safari did not set the value currentColor correct for the svg when visited state was on. The solution was to add a more specific css selector that targeted the svg path:

    .hds-link:visited svg g path {
       fill: var(--link-visited-color);
    }