Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The :target-within
CSS pseudo-class represents an element that is a target element or contains an element that is a target. A target element is a unique element with an id
matching the URL's fragment. In other words, it represents an element that is itself matched by the :target
pseudo-class or has a descendant that is matched by :target
. (This includes descendants in shadow trees.)
/* Selects a <div> when one of its descendants is a target */ div:target-within { background: cyan; }