v147 · CSS · Events
Pseudo target on events
UIEvent, AnimationEvent, and TransitionEvent now expose a .pseudoTarget property — when the event originates from a CSS pseudo-element (::before, ::after, ::marker, …) it returns the CSSPseudoElement instead of null.
concepts
-
Pseudo-element Click Lab
A grid of styled elements with
::beforeand::afterdecorations. Click anywhere — the event log shows whetherevent.pseudoTargetreturns aCSSPseudoElementornull, making the click origin unambiguous. -
Animation Origin Tracker
Kick off CSS animations on elements and their pseudo-elements simultaneously. An
animationendlistener reads.pseudoTargetto attribute each event to the exact layer — element or::beforeor::after— without any extra DOM wrappers. -
Pseudo-element Event Tree Explorer
Click elements that have
::before,::after, and::markerpseudo-elements. The event inspector showsevent.pseudoTargetvsevent.targetlive, and tallies how many clicks originated from each pseudo-element type. -
Tooltip Reveal
Tooltips built entirely in
::afterpseudo-elements. When the tooltip'stransitionendfires,event.pseudoTargetidentifies it came from::after— the handler locks the tooltip green to confirm receipt, demonstratingpseudoTargetonTransitionEvent. -
Compatibility Lab
Detects
event.pseudoTargetonUIEvent,AnimationEvent, andTransitionEvent. Click a card with::before/::afterdecorators and watch whetherpseudoTargetresolves aCSSPseudoElement— or falls back to geometry checks viaElement.pseudo().
why it shipped
CSS pseudo-elements (::before, ::after, ::marker, ::first-letter) are rendered by the browser but have no DOM node. When a user clicked on a ::before decoration, event.target always pointed at the originating element — you had to use geometry checks or pointer-events tricks to guess whether the pseudo-element was involved. .pseudoTarget fills that gap: when the event originates from a pseudo-element, .pseudoTarget is the CSSPseudoElement returned by Element.pseudo(); otherwise it is null. This pairs naturally with the CSSPseudoElement interface that also shipped in Chrome 147, making pseudo-elements full participants in event-driven JavaScript without any heuristics.
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗