Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining multiple pseudo-selectors

Tags:

html

css

It appears that at one point in time combining multiple pseudo-selectors was possible. For example, one could do this:

a:visited:hover {color: red}

A quick Google search reveals multiple examples of this in action, here, here, and here. I am unable to get this feature to work in the latest versions of Safari, Firefox, or Chrome. Can anyone explain why this feature has regressed and/or been handicapped?

like image 519
colindunn Avatar asked Nov 06 '11 04:11

colindunn


1 Answers

The :visited pseudoclass can't be used for most styling in a lot of modern browsers anymore because it's a security hole. See this link for a more formal discussion on it.

The short version is that if you can style :visited links differently, you can use that to determine if people have visited various sites, and therefore target them based on their browser history. Most modern browsers therefore heavily restrict the styling that can be done on them.

You can still chain pseudoselectors. For example, a:focus:hover works just fine to apply styles only if the element is focused AND hovered. See this link for a demonstration.

like image 58
Chris Heald Avatar answered Oct 22 '22 23:10

Chris Heald