css sibling selector

Given this HTML, how do I target the <div data-rehype-pretty-code-title> only if the SVG with data-language-icon is present? I'm guessing some ~ ?
3 Replies
julius
julius15mo ago
i only manage to target the icon and not the title :/
cornflour
cornflour15mo ago
you can do this
[data-rehype-pretty-code-title]:has(+ [data-language-icon="true"]) {
/* Your css here */
}
[data-rehype-pretty-code-title]:has(+ [data-language-icon="true"]) {
/* Your css here */
}
or if the svg doesn't need to be the very next child
[data-rehype-pretty-code-title]:has(~ [data-language-icon="true"]) {
/* Your css here */
}
[data-rehype-pretty-code-title]:has(~ [data-language-icon="true"]) {
/* Your css here */
}
firefox doesnt seem to support has selector by default yet though :( https://caniuse.com/css-has
julius
julius15mo ago
Thanks 🙏