Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot change padding on visited links?

Tags:

html

css

Why I am unable to change padding for the visited link? I am trying this:

HTML:

<a href="#">link</a>

CSS:

a{
    display: block;
    background: green;
    padding-left: 100px;
}

a:visited{
   background: red;
   padding-left: 0;
}

Demo: http://jsfiddle.net/ZVZWW/

like image 341
user1251698 Avatar asked Jan 13 '23 05:01

user1251698


2 Answers

Unfortunately, due to security concerns, the list of styles you are allowed to apply to :visited elements is limited. In the past, hackers have been able to sniff history from users by checking for differences in styles of normal links, and ones the user had previously visited. More on the security concerns here, and what styles are allowed: https://blog.mozilla.org/security/2010/03/31/plugging-the-css-history-leak/

As for allowed styles and modifications to :visited elements, here is a what MDN has documented on the subject:

You will still be able to visually style visited links, but there are now limits on what styles you can use. Only the following properties can be applied to visited links:

color
background-color
border-color (and its sub-properties)
outline-color
fill and stroke colors

In addition, even for the properties you can set for visited links, you won't be able to change the transparency between unvisited and visited links, as you otherwise would be able to using rgba() or hsla() color values or the transparent keyword.

like image 143
csuwldcat Avatar answered Jan 19 '23 22:01

csuwldcat


Only the following properties can be applied to visited links:

color      
background-color
border-color (and its sub-properties)
outline-color

Source : - Privacy_and_the_:visited_selector

like image 21
swapnesh Avatar answered Jan 20 '23 00:01

swapnesh