How to hide a part of text in markdown cell?

Hello, how can i hide part of text in markdown cell? I want to have in one cell Question and hidden answer with button to unhide the answer if possible. I have tried some examples with toggle which are on jupyter webpage. None of the examples was working in the notebook? I wasn’t successfull in hiding part of the text in the cell. Do you have any advice?

Traditionally, I’ve used what is at the top here. This should make a collapsible section with a toggle that rotates as you toggle it to show or hide.
However, I see that it sort of works in Jupyter notebook classic interface because it shows the bracketed content if you click the text and hides it again if you click again, I see it right now isn’t showing the arrow that rotates for the different states. I’ve seen this arrow indicator named the ‘expand icon’ or ‘HTML5 drop-down character’. It is associated with <summary></summary> /<details></details> sections.

It works 100% right now in JupyterLab. In the past it had worked that way in the classic notebook interface as well.

I imagine it is a glitch someone else has noticed; however, there is a chance it hasn’t been reported yet. (See UPDATE below.)

Since it sort of works, is that enough for now for your use case? You could maybe emphasize to click the text with something like this:

# A collapsible section within markdown

### Question 

What symbol is ...?  
<br></br>

<details>
    <summary>Click once on <font color="red"><b>this text</b></font> to hide/unhide the answer!</summary>
  
  ### Answer
  The answer is the arrow thingy...
</details>

# Another example of collapsible section with markdown

<details>
  <summary>Click to expand!</summary>
  
  ## Heading
  1. A numbered
  2. list
     * With some
     * Sub bullets
</details>

UPDATE:
Maybe issue post #2223 at jupyter/notebook is the issue posting about this? Strangely though, I thought this worked more recently than 2017 in the classic interface.
I wonder if since this works in JupyterLab now, it will just sort itself out when the underlying workings will soon be much more the same in notebook 7.0?

1 Like

Thank you very much. Your answer was very helpful.