Can i force every summary/details pair to be collapsed when study by default?

you may know that you can use the html summary/details tag to hide a block e.g. a paragraph after a Q.

whether this block is shown/hide depend on the last status in the editor.

many times i didn’t collapse it thus the next time i study it, the answer is shown already.

can i do something to prevent this?

i am empowered by gpt4 in plus plan so i could do more than a layman does. thx

gpt4 code interpreter:

the above is a code i cant show in mobile…

will try later.


document.addEventListener(‘DOMContentLoaded’, (event) => {
const details = document.querySelectorAll(‘details’);
details.forEach((detail) => {

Have you, by any chance, put the <details> and <summary> tag in the source HTML of the card? Because i can only replicate the behavior you describe, if i do so. To solve your issue, i think there are two possible solutions.

Approach 1 - Rely on HTML and Anki

Open the front template of your card type. You get there by clicking on “edit” when reviewing a card, or by clicking on “cards…” when viewing the card in the browser.

Then put the HTML tags in the front template of the card type like so:


{{MyQuestionField}} and {{MyExtraInfoField}} need to match exactly with two fields in your note type.

After you have done this, Anki should hide the detailed information on every reload of your card.

Of course, you will need to put the detailed information in the {{MyExtraInfoField}}, instead of putting it all in your Question field. In addition, you will want to delete all the HTML tags in the source of your Question field. So if you have a lot of cards created already, you will unfortunately have to edit all of them. If you don’t have a lot of cards to edit, then i think this is the preferred approach, because you rely on the default behavior of Anki and don’t need any additional JavaScript.

Approach 2 - Use JavaScript

If you do have a lot of cards already made, and don’t want to edit them all, add the following JavaScript in the front template of your card type.

    document.querySelector("details").open = false;
1 Like

hey brother,

your code works, thanks.

indeep i asked the same from GPT4’s code interpreter, but the code it suggested didn’t work

I am a med student like many others here.
GPT4 could got 85% correct in USMLE, which indeep is better than i think half of my fellow classmates.
you let me know that still it cannot replace human. Thanks

document.addEventListener('DOMContentLoaded', (event) => {
  const details = document.querySelectorAll('details');
  details.forEach((detail) => {

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.