From the command line, transform CSS files that use
npx focus-within SOURCE.css TRANSFORMED.css
Next, use your transformed CSS with this script:
That’s it. The script is 379 bytes and works in all browsers, including Internet Explorer 9.
How it works
The PostCSS plugin duplicates rules containing
:focus-within, replacing them with an alternative
/* becomes */
attribute to elements otherwise matching
FieldFieldSome sibling text element.
One cannot simply add the
[focus-within]selector to an existing rule:
Browsers that don't support
:focus-withinwill throw the entire rule away! This is why you should follow the Usage instructions.