htmlcollapsable

Collapsible text under title


I am trying to make a text collapsible when I press the word 'Abstract' in my webpage, https://rubencioak.github.io/research.html, I thought the following code was going to be enough:

<ol class="lead">

<li> <p> <b>Free-riding in Collective Agreements,a Search and Matching Model of Minimum Wages</b> 
<br />  

<span id="abstract-link" class="abstract-click">Abstract</span>
<p class="abstract-text" style="display:none; font-size:.90em">Does free riding in collective... unemployment, at a cost of employed earning less</p>

</p> </li> </ol>

I am using a templeate from HTML5 and also looking at this webpage: https://messertodd.github.io/research.html. for reference.

Now, although I thought it was basically the same, something is obviously wrong with this code.

All in all, the question is: is there a simple way to make my text under the word abstrac collapsible?

Any help would be much appreciated.

KR


Solution

  • You can use <details> and <summary> tags:

        <details>
            <summary>Abstract</summary>
            <p class="abstract-text" style="font-size:.90em">Does free riding in collective... unemployment, at a cost of employed earning less</p>
        </details>