Help:Collapsing
this wiki
Collapsing is a feature to collapse (or hide) any HTML element.
There are times when a page can contain many related elements which makes it very long; using a collapsing feature enables editors to shorten the page, and allow readers to expand areas of interest to them. Similar to the Table of Contents, other parts of a wiki page can be designed to collapse.
To make an element collapsible, simply add the class "mw-collapsible" to it.
Examples
Edit
Collapsing a table
Edit
By adding "mw-collapsible" as the class, a table can be collapsed to save page space.
| Number | Letter |
|---|---|
| 1 | A |
| 2 | B |
| 3 | C |
{| class="article-table mw-collapsible" style="float:right"
! Number !! Letter
|-
| 1 || A
|-
| 2 || B
|-
| 3 || C
|}
Collapsing text
Edit
It is possible to collapse text in an article, effectively shortening the page, and allowing the reader to decide if they want to read the rest of the information. For example:
This text is collapsible.
</div>
Results in:
Advanced settings
Edit
Initial state
Edit
To set the initial state as collapsed add "mw-collapsed" along with "mw-collapsible", such as seen in the following table:
{| class="mw-collapsible mw-collapsed article-table"
! The header !! remains visible
|-
| This content || is hidden
|-
| until 'Expand' || is clicked
|}
| The header | remains visible |
|---|---|
| This content | is hidden |
| until 'Expand' | is clicked |
Selecting collapsible content
Edit
You can also specify which part is the collapsible content by using "mw-collapsible-content".
This text is not collapsible; but the next is collapsible and hidden by default:
<div class="mw-collapsible-content">This text should be hidden by default.</div>
This text should be visible as well.
</div>
Results in:
This text is not collapsible; but the next is collapsible and hidden by default:
This text should be visible as well.
Custom wording
Edit
Don't like 'Expand'/'Collapse' for the links? No problem! Change them using "data-expandtext" and "data-collapsetext".
{| class="article-table mw-collapsible" data-expandtext="Illuminate" data-collapsetext="Deluminate"
! My || Header
|-
| A || B
|-
| C || D
|}
| My | Header |
|---|---|
| A | B |
| C | D |
Note: to change these links site-wide would require editing MediaWiki:Collapsible-expand and MediaWiki:Collapsible-collapse.
Toggle button
Edit
If you notice in the example table above, the link in the second column really increases the width of the table compared to the text within it. We can fix that by having the toggle placed anywhere else on the page.
To do that, we have to assign an ID to the element. This ID must be prefixed with "mw-customcollapsible-" and followed by a unique key phrase for that element. Using our table above, we can add the ID "mw-customcollapsible-myTable".
That takes care of the table itself. Next, we have to add a button/link/text element with the class "mw-customtoggle-myTable" (note this is a class and not an ID like above).
{| class="article-table mw-collapsible" id="mw-customcollapsible-myTable"
! My || Header
|-
| A || B
|-
| C || D
|}
<div class="mw-customtoggle-myTable wikia-menu-button">Show/Hide table</div>
| My | Header |
|---|---|
| A | B |
| C | D |
See Also
Edit
Further Help & Feedback
Edit
- Browse and search other help pages at Help:Contents
- Check FANDOM Community Central for sources of further help and support
- Check Contacting FANDOM for how to report any errors or unclear steps in this article
- Learn how to use Fandom in FANDOM University: short how-to videos for all levels of experience