In my application I need to change the font size of the links that are visited. What I'm doing is
a:visited {
color: pink;
font-size:12px;
}
But only the color is getting changed. Why is the font size not changing ?
In my application I need to change the font size of the links that are visited. What I'm doing is
a:visited {
color: pink;
font-size:12px;
}
But only the color is getting changed. Why is the font size not changing ?
Limitations of :visited
The :visited
pseudoselector has some limitations with regards to what properties it can target and sadly font-size
isn't one of them :
Acceptable Properties
As seen above, the only acceptable styles that can be targeted are :
color
background-color
border-color
border-{bottom,left,right,top}-color
outline-color
column-rule-color
This is done for security/privacy reasons and isn't likely going to change any time soon. If you really had to implement this, you would likely need to resort to some Javascript to explicitly set the size on your visited tags.
Browsers limits the styles that can be set for a:visited links, due to security issues.
Allowed styles are:
All other styles are inherited from a:link.
You can only change any color of visited (:visited) links but not the size. You can only change the size of a:link {font-size: 150%} of "NOT" visited links
So all the other answers have established that this can not be done with pure CSS. So JavaScript to the rescue.
https://jsfiddle.net/dustinpoissant/708fwntf/
$(function(){
$("a").each(function(index, link){
var $link = $(link);
console.log($link.css("color"));
if($link.css("color") == "rgb(0, 0, 238)"){
$link.addClass("visited");
}
})
});
a:visited {
color: pink;
}
a.visited {
font-size: 26px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#">Test</a>