HTML ontoggle Attribute

❮ HTML Attributes


<details ontoggle="myFunction()">
<p>The first version of HTML was written by Tim Berners-Lee in 1993. Since then, there have been many different versions of HTML. The most widely used version throughout the 2000`s was HTML 4.01, which became an official standard in December 1999.</p>


The ontoggle attribute specifies the script to be run when the user opens or closes the <details> element.

Standard Syntax

<element ontoggle="script">

Browser Support


Applies to:

The ontoggle attribute can be used on the following element:

Element Attribute
<details> ontoggle

Attribute Values

Value Description
script Specifies the script to be run on ontoggle
❮ HTML Attributes