23 мар. 2018 г.

Frequently forgotten limitations of the :visited link selector


  • Sibling selectors like :visited + span don't work in CSS
  • Nested selectors like :visited div don't work in CSS
  • :visited link can be styled only via
    • color
    • background-color
    • border-color
    • column-rule-color
    • outline-color
    • fill (color only)
    • stroke (color only)
  • You cannot change the transparency of the above mentioned allowed rules via color: rgba() or similar techniques, i.e.
    a {color: rgba(128, 0, 0, 0.5)} a:visited {color: rgba(0, 128, 0, 0.1)}
    is effectively equal to
    a {color: rgba(128, 0, 0, 0.5)} a:visited {color: rgba(0, 128, 0, 0.5)}
  • window.getComputedStyle, element.querySelector etc. won't detect :visited link



Reference to the MDN documentation page: https://developer.mozilla.org/en-US/docs/Web/CSS/Privacy_and_the_:visited_selector