Using HTML 5 Details/Summary Tag

WordPress filters the markup used in post content as a security measure. This stops people inserting malicious javascript inside comments or posts.

On a non-multisite install, administrators sometimes have the unfiltered html capability allowing them to bypass this, but this is a dangerous feature

In particular, the wp_kses_post function replicates this functionality and maintains the whitelist WP uses.

A more compatible approach would be to use a shortcode. However, if you can do what you need to do within the WP UI, then you should do that, and focus on changing the default markup used via actions/filters, rather than inserting your own by hand