I have a div block with a class “help-image” that contains an <img>, inside a section with a class “help-section”.
Using the :has selector as follows works fine:
section.help-section > div:has(img),
section.help-section > div:has(figure),
section.help-section > div:has(button)
{
background: mistyrose;
}
However, passing a list of elements (as the MDN docs suggest I can) doesn’t work at all:
section.help-section > div:has(img, button, figure)
{
background: mistyrose;
}
I have inspected all elements with the developer tools, and the rule does not appear at all if I use the second example.
New contributor
alexjfox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2