79153338

Date: 2024-11-03 18:08:06
Score: 0.5
Natty:
Report link

I know this question is old but since I still found it in 2024, here's an update:

The :has() pseudo-selector class can be used to access its parent elements.

div.with-link:has(> a:target) {
    background: yellow
}

Note that this method requires you to define a parent selector div.with-link in this case. All elements matching this selector that have the target in them will be highlighted.

All major browsers support this selector. Refer to https://caniuse.com/css-has to check if your target browser or browser versions have support for it.

If this does not fit your requirements, you may still fall back to the JavaScript alternative.

Source: https://stackoverflow.com/a/1014958/1457596

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: spiegelm