Combining multiple pseudo-selectors

后端 未结 1 486
遥遥无期
遥遥无期 2021-01-05 04:49

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}

相关标签:
1条回答
  • 2021-01-05 05:12

    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.

    0 讨论(0)
提交回复
热议问题