Events

ontransitionstart

A CSS transition starts its active interval after its delay. Event defined by a related web API or specification, not simply a portable HTML global handler. Use addEventListener on the actual target; inline handler exposure and browser support may differ. Event interface: TransitionEvent. For the described native event: bubbles: yes; cancelable: no. Contrast with transitionrun, which can fire even if the transition is canceled during the delay. Example: Click Toggle effect; for cancellation, toggle again before the effect finishes. The event listener is registered with addEventListener(), which avoids inline script handlers and supports multiple listeners. Inline handlers require a CSP that permits them; do not insert untrusted code into handler attributes.

Formal Syntax & Structure

html syntaxhtml
target.addEventListener("transitionstart", event => { /* handle event */ });

Parameters & Attributes

NameTypeDescription
eventTransitionEventEvent object delivered to the addEventListener callback; event.type is "transitionstart". Inspect target, currentTarget, bubbles and cancelable as appropriate.

Working Example

Example Snippethtml
<style>  @keyframes pulse { from { opacity: 1; } to { opacity: .4; } }  #demo { width: 100px; padding: 16px; background: lightblue; transition: opacity .4s .2s; }  #demo.active { opacity: .4; }</style><div id="demo">Preview</div><button id="start" type="button">Toggle effect</button><p role="status" id="log">Waiting for transitionstart</p><script>  const target = document.getElementById("demo");  const log = document.getElementById("log");  target.addEventListener("transitionstart", event => {    log.textContent = String(event.propertyName);  });  document.getElementById("start").onclick = () => target.classList.toggle("active");</script>
HTML Reference