I have a problem with code given below - is it possible to modify styling of a sibling of an element using :visited? Or maybe in JS it is possible somehow?
Here is a codepen that I'm working on: https://codepen.io/kuba-pisula/pen/MWBYaXX
HTML:
<div >
<a
href="https://www.google.com"
></a>
<div >
<h2 >
test
</h2>
</div>
</div>
SCSS:
.container {
&:has(> a:visited) {
background-color: red;
h2 {
color: brown !important;
}
}
}
I have also tried:
.container {
a:visited .content {
background-color: red;
h2 {
color: brown;
}
}
}
CodePudding user response:
What you are attempting will not work due to privacy concerns.
If you use a sibling selector (combinator) like :visited span
then the span will be styled as if the link were unvisited.