Bootstrap 5 Carousel With Controls Last Updated : 23 Jul, 2025 Suggest changes Share 2 Likes Like Report Bootstrap 5 Carousel With controls means we can add controls to the Carousel for changing the slides of the carousel. Note: This can be achieved using HTML <button> as well as HTML <a> tag.Bootstrap 5 Carousel With Controls Classes:carousel-control-prev: This class is used for the carousel previous control.carousel-control-next: This class is used for the carousel next control.carousel-control-prev-icon: This class is used for the carousel previous icon image.carousel-control-next-icon: This class is used for the carousel next icon image.Syntax:<button class="carousel-control-prev" type="button" data-bs-target="#GFG" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"> ... </span> <span class="visually-hidden">...</span></button>Example 1: In this example, we will learn about Carousel Controls using the HTML <button> tag. HTML <!DOCTYPE html> <html> <head> <!-- Bootstrap CDN --> <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css" integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" crossorigin="anonymous"> <script src= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js" integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" crossorigin="anonymous"> </script> </head> <body class="m-2 text-center"> <div> <h1 class="text-success"> GeeksforGeeks </h1> <h3>Bootstrap 5 Carousel With controls</h3> <div id="GFG" class="carousel slide carousel-fade" data-ride="carousel"> <!-- The slideshow --> <div class="carousel-inner"> <div class="carousel-item active"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" height="400px" width="400px" alt="Java" class="d-block w-100"> </div> <div class="carousel-item"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20220401124017/HTML-Tutorial.png" height="400px" width="400px" alt="HTML" class="d-block w-100"> </div> <div class="carousel-item"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210322182256/AngularJS-Tutorial.png" height="400px" width="400px" alt="Angular" class="d-block w-100"> </div> <button class="carousel-control-prev" href="#GFG" data-slide="prev"> <span class="carousel-control-prev-icon"> </span> </button> <button class="carousel-control-next" href="#GFG" data-slide="next"> <span class="carousel-control-next-icon"> </span> </button> </div> </div> </div> </body> </html> Output:Example 2: In this example, we will learn about Carousel Controls using an HTML <a> tag. We need to add role="button" in <a> tag. HTML <!DOCTYPE html> <html> <head> <!-- Bootstrap CDN --> <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css" integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" crossorigin="anonymous"> <script src= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js" integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" crossorigin="anonymous"> </script> </head> <body class="m-2 text-center"> <div> <h1 class="text-success"> GeeksforGeeks </h1> <h3>Bootstrap 5 Carousel With Controls</h3> <div id="GFG" class="carousel slide carousel-fade" data-ride="carousel"> <!-- The slideshow --> <div class="carousel-inner"> <div class="carousel-item active"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" height="400px" width="400px" alt="Java" class="d-block w-100"> </div> <div class="carousel-item"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20220401124017/HTML-Tutorial.png" height="400px" width="400px" alt="HTML" class="d-block w-100"> </div> <div class="carousel-item"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210322182256/AngularJS-Tutorial.png" height="400px" width="400px" alt="Angular" class="d-block w-100"> </div> <a class="carousel-control-prev" href="#GFG" data-slide="prev" role="button"> <span class="carousel-control-prev-icon"> </span> </a> <a class="carousel-control-next" href="#GFG" data-slide="next" role="button"> <span class="carousel-control-next-icon"> </span> </a> </div> </div> </div> </body> </html> Output:References: https://getbootstrap.com/docs/5.0/components/carousel/#with-controls Create Quiz 21mcsrltd Follow 2 Article Tags : Technical Scripter Web Technologies Bootstrap Technical Scripter 2022 Explore LayoutBootstrap 5 Introduction 4 min read Bootstrap 5 Layout Breakpoints 3 min read Bootstrap 5 Layout Containers 3 min read BootStrap 5 Layout Grid System 3 min read Bootstrap 5 Columns 2 min read Bootstrap 5 Gutters 2 min read Bootstrap 5 Utilities 2 min read Bootstrap 5 Z-index 2 min read ContentBootstrap Reboot 2 min read Bootstrap 5 Typography 2 min read Bootstrap 5 Images 1 min read Bootstrap 5 Tables 2 min read Bootstrap 5 Figures 2 min read FormsBootstrap-5 Forms 2 min read Bootstrap 5 Form Controls 2 min read Bootstrap 5 Select 2 min read Bootstrap 5 Checks and Radios 2 min read Bootstrap 5 Range 2 min read Bootstrap 5 Input Group 3 min read Bootstrap 5 Floating labels 2 min read Forms LayoutBootstrap 5 Layout Forms 2 min read Bootstrap5 Layout Utilities 2 min read Bootstrap 5 Layout Form Grid 2 min read Bootstrap 5 Layout Gutters 2 min read Bootstrap 5 Layout Horizontal form 2 min read Bootstrap 5 Layout Horizontal form label sizing 2 min read Bootstrap 5 Layout Column sizing 2 min read Bootstrap 5 Layout Auto-sizing 2 min read Bootstrap 5 Layout Inline forms 2 min read Bootstrap 5 Validation 4 min read ComponentsBootstrap 5 Accordion 3 min read Bootstrap 5 Alerts 2 min read Bootstrap 5 Badges 2 min read Bootstrap Breadcrumb 2 min read Bootstrap 5 Buttons 3 min read Bootstrap 5 | Button group 4 min read Bootstrap 5 | Card 11 min read Bootstrap 5 Carousel 3 min read Bootstrap 5 | Close button 1 min read Bootstrap 5 Collapse 3 min read Bootstrap 5 Dropdowns 9 min read Bootstrap 5 List group 5 min read Bootstrap 5 Modal 7 min read NavbarBootstrap 5 Navbar Brand 3 min read Bootstrap 5 Navbar Brand Text 2 min read Bootstrap Navbar Brand Image 2 min read Bootstrap 5 Navbar Nav 2 min read Bootstrap 5 Navbar Forms 2 min read Bootstrap 5 Navbar Text 2 min read Bootstrap 5 Offcanvas 12 min read Bootstrap 5 Popovers 2 min read Bootstrap 5 Progress 5 min read Bootstrap 5 Scrollspy 4 min read Bootstrap 5 Spinners 3 min read Bootstrap 5 Toasts 3 min read Bootstrap 5 Tooltips 3 min read HelpersBootstrap 5 Clearfix 2 min read Bootstrap 5 Colored links 2 min read Bootstrap 5 Ratios 2 min read Bootstrap 5 Position 2 min read Bootstrap 5 Visually hidden 2 min read Bootstrap 5 Stretched link 2 min read Bootstrap 5 Text Truncation 2 min read ExtendBootstrap 5 Approach 3 min read Bootstrap 5 Icons 2 min read UtilitiesBootstrap 5 Background 2 min read Bootstrap 5 Borders 2 min read Bootstrap 5 Colors 3 min read Bootstrap 5 Display 3 min read Bootstrap 5 Flex 3 min read Bootstrap 5 Float 3 min read Bootstrap 5 Interactions 3 min read Bootstrap 5 Overflow 2 min read ReferencesBootstrap 5 Layout Complete Reference 5 min read Bootstrap 5 Content Complete Reference 7 min read Bootstrap 5 Forms Reference 7 min read Bootstrap 5 Components Reference 15+ min read Bootstrap 5 Helpers Reference 2 min read Bootstrap 5 Utility Reference 11 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like