Html & Html5

The World's best Software Development Study Portal

Bootstrap Carousel

Basically Carousel is that property by which we can add slider in our webpage which will be responsive one. We can add content, iframe, images , videos etc. whatever we want to add

Let’s understand this by the following program in which we show the slider for images:-

<!DOCTYPE html>

<html lang="en">


<title> bootstrap 4 Example</title>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">


/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 100%;



<div id="demo" class="carousel slide" data-ride="carousel">

<ul class="carousel-indicators">

<li data-target="#demo" data-slide-to="0" class="active"></li>

<li data-target="#demo" data-slide-to="1"></li>

<li data-target="#demo" data-slide-to="2"></li>


<div class="carousel-inner">

<div class="carousel-item active">

<img src="pythonimage/tajmahal.jpg" alt="Taj Mahal" width="500" height="300">


<div class="carousel-item">

<img src="pythonimage/redfort.jpg" alt="Red Fort" width="500" height="300">


<div class="carousel-item">

<img src="pythonimage/goldentemple.jpg" alt="Golden Temple" width="500" height="300">



<a class="carousel-control-prev" href="#demo" data-slide="prev">

<span class="carousel-control-prev-icon"> </span>


<a class="carousel-control-next" href="#demo" data-slide="next">

<span class="carousel-control-next-icon"> </span>





Output of this Program

So here our carousel is ready here.

Here are some other classes of carousel which we can use in bootstrap. Some of the classes and their description is stated as follows:-

Class Description
.carousel Creates a carousel
.carousel-indicators Adds indicators for the carousel. These are the little dots at the bottom of each slide (which indicates how many slides there are in the carousel, and which slide the user are currently viewing)
.carousel-inner Adds slides to the carousel
.carousel-item Specifies the content of each slide
.carousel-control-prev Adds a left (previous) button to the carousel, which allows the user to go back between the slides
.carousel-control-next Adds a right (next) button to the carousel, which allows the user to go forward between the slides
.carousel-control-prev-icon Used together with .carousel-control-prev to create a "previous" button
.carousel-control-next-icon Used together with .carousel-control-next to create a "next" button
.slide Adds a CSS transition and animation effect when sliding from one item to the next. Remove this class if you do not want this effect

Bootstrap 4 training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute