Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
details:not([open]) > :not(summary) {display: none;}
@mathiasbynens

For future reference, this fallback is only targeted at modern browsers. .querySelectorAll and .hasAttribute are only supported in IE8+. addEventListener works in IE9+.

Also it won’t take care of the edge case where direct child text nodes are part of the <summary> (as the CSS rule details:not([open]) > :not(summary) {display: none;} won’t target those).

If you ever need a more robust (but slightly heavier) solution, feel free to use http://mathiasbynens.be/notes/html5-details-jquery :)

@joneff
Owner

And so is :not ;)

If I was worrying about IE6 not being able to display this snippet, I wouldn't have written in the first place. Sometimes (especially when possible) one should really take advantage of technology regardless the legacy players out there.

@mathiasbynens

If I was worrying about IE6 not being able to display this snippet, I wouldn't have written in the first place.

Sure — please don’t get me wrong, I’m just pointing it out so less experienced developers don’t get bitten by the lack of browser support. If you only need to support modern browsers (and you don’t need to account for every possible edge case), this is a lovely lightweight snippet!

@joneff
Owner

Also it won’t take care of the edge case where direct child text nodes are part of the

(as the CSS rule details:not([open]) > :not(summary) {display: none;} won’t target those).

Point taken

@mathiasbynens

Btw, the code in the separate .js seems to differ from the JavaScript in the HTML. Just a heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.