Collapsible Sections / Accordions
Collapsible sections or "accordions" are another way to organize long documents or pages, while taking up less screen space. Readers can flip between the sections of your document by clicking or tapping to expand one section of the document at a time. Below is an example of collapsed and expanded accordion respectively.
image
image
To create collapsible sections in your content:
  1. 1.
    Under Text Format, ensure your page is set to "Full HTML" instead of "Filtered HTML"
  2. 2.
    Click the Source button on the editor toolbar to switch the editor to source editing mode
image
  1. 1.
    Copy and paste the following markup into the source editor
image
  1. 1.
    Adjust the number and description of the sections to suit your content. When adding a new accordion section to your code, remember to update the values in the new section that reference "headingThree" or "collapseThree" so that the new section has unique values on the page (e.g. headingFour, collapseFour).

Markup

The following markup will show three accordion sections. All sections are closed when users initially load the page.
1
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
2
3
<div class="panel panel-default">
4
<div class="panel-heading" role="tab" id="headingOne">
5
<h4 class="panel-title">
6
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
7
Collapsible Group Item #1
8
</a>
9
</h4>
10
</div>
11
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
12
<div class="panel-body">
13
...
14
</div>
15
</div>
16
</div>
17
18
<div class="panel panel-default">
19
<div class="panel-heading" role="tab" id="headingTwo">
20
<h4 class="panel-title">
21
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
22
Collapsible Group Item #2
23
</a>
24
</h4>
25
</div>
26
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
27
<div class="panel-body">
28
...
29
</div>
30
</div>
31
</div>
32
33
<div class="panel panel-default">
34
<div class="panel-heading" role="tab" id="headingThree">
35
<h4 class="panel-title">
36
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
37
Collapsible Group Item #3
38
</a>
39
</h4>
40
</div>
41
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
42
<div class="panel-body">
43
...
44
</div>
45
</div>
46
</div>
47
48
</div>
Copied!
If you wanted the first accordion section to appear open for users by default, you would update the first section as follows:
1
<div class="panel panel-default">
2
<div class="panel-heading" role="tab" id="headingOne">
3
<h4 class="panel-title">
4
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
5
Collapsible Group Item #1
6
</a>
7
</h4>
8
</div>
9
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
10
<div class="panel-body">
11
...
12
</div>
13
</div>
14
</div>
Copied!
To add additional (closed) sections, add the following code directly below the last accordion section and above the closing </div> tag. Remember to update any values referencing "headingThree" or "collapseThree" so it is unique on the page (e.g. headingFour, collapseFour).
1
<div class="panel panel-default">
2
<div class="panel-heading" role="tab" id="headingThree">
3
<h4 class="panel-title">
4
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
5
Collapsible Group Item #3
6
</a>
7
</h4>
8
</div>
9
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
10
<div class="panel-body">
11
...
12
</div>
13
</div>
14
</div>
Copied!
Copy link
Contents
Markup