v147 · CSS · demo
Pseudo-element Click Lab
Click anywhere on the cards below — including the ::before and ::after decorations. The event log shows whether event.pseudoTarget returned a CSSPseudoElement or null.
::before star badge
Card A
::before arrow
Card B
::after arrow text
Card C
::before underline bar
Card D
::after corner tag
Card E
Click log
Click a card or its decoration to see events here.
// Chrome 147 — pseudoTarget on click events
document.querySelectorAll('.click-target').forEach(el => {
el.addEventListener('click', event => {
const pseudo = event.pseudoTarget; // CSSPseudoElement | null
if (pseudo) {
console.log('Clicked pseudo-element:', pseudo.type);
// pseudo.type: '::before', '::after', '::marker', etc.
} else {
console.log('Clicked element itself:', event.target.id);
}
});
});
see also
- Animation Origin Tracker — animationend events with pseudoTarget
- Back to feature index
- ChromeStatus entry
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗