Open In App

What is the use of the Collapse Class in Bootstrap ?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The .collapse class in Bootstrap is utilized to create collapsible content sections that can be toggled to show or hide. It allows developers to efficiently manage space on a webpage by hiding less relevant content initially and revealing it when needed, thereby improving user experience and content organization.

  • .collapse: It hides the content.
  • .collapsing: It is applied during transitions.
  • .collapse.show: It shows the content.

Syntax:

<div class="collapse">
<!-- Collapsible content goes here -->
</div>

Explanation: When applied to an HTML element, such as <div>, the .collapse class hides the content within by default. This content can then be revealed or hidden by triggering events such as clicks on buttons or links with the appropriate Bootstrap JavaScript methods. The .collapse class provides a simple and effective way to implement collapsible sections, enhancing the usability and organization of web pages.

Features:

  • Enables creation of collapsible content sections on webpages.
  • Efficiently manages space by hiding less relevant content initially.
  • Improves user experience and content organization.
  • Content can be revealed or hidden by triggering events like clicks.
  • Simple and effective implementation for collapsible sections.

Ref: https://www.geeksforgeeks.org/bootstrap-4-collapse/


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads