Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Images

Bootstrap provides useful classes to make images responsive, rounded, circular, thumbnail-style, aligned and properly displayed on different devices.

Simple Explanation: Bootstrap image classes help us control the appearance and responsiveness of images without writing a lot of custom CSS.

What are Images?

Images are visual elements used to display photos, graphics, logos, banners and other visual content on a web page.

In HTML, images are normally displayed using the <img> element.

Example: Bootstrap provides classes such as .img-fluid, .rounded, .rounded-circle and .img-thumbnail.

1. Basic Image

A normal HTML image can be displayed using the <img> tag.

<img src="/Images/Boostrap/Image1.png"
     alt="Bootstrap Basic Image">
Output:
Bootstrap Basic Image

2. Responsive Images

Responsive images automatically adjust their size according to the available screen width.

Bootstrap provides the .img-fluid class for responsive images.

<img src="/Images/Boostrap/Image2.png"
     class="img-fluid"
     alt="Responsive Image">
Important: .img-fluid applies max-width: 100% and height: auto.
Responsive Image

3. Rounded Images

The .rounded class adds rounded corners to an image.

<img src="/Images/Boostrap/Image3.png"
     class="img-fluid rounded"
     alt="Rounded Image">
Output:
Rounded Image

4. Circular Images

The .rounded-circle class makes an image circular.

<img src="/Images/Boostrap/Image4.png"
     class="rounded-circle"
     alt="Circular Image">
Output:
Circular Image

5. Image Thumbnail

The .img-thumbnail class creates an image with a border and rounded corners.

<img src="/Images/Boostrap/Image5.png"
     class="img-thumbnail"
     alt="Thumbnail Image">
Output:
Thumbnail Image

6. Align Image to the Left

Bootstrap's .float-start utility can be used to move an image toward the start of the container.

<img src="/Images/Boostrap/Image2.png"
     class="float-start me-3 rounded"
     alt="Left Image">
Left Image

This text appears beside the image. The me-3 class provides spacing between the image and the text.

7. Align Image to the Right

The .float-end class moves an image toward the end of the container.

<img src="/Images/Boostrap/Image3.png"
     class="float-end ms-3 rounded"
     alt="Right Image">
Right Image

This text flows around the image. The ms-3 class adds spacing between the text and image.

8. Center an Image

To center an image, we can use d-block together with mx-auto.

<img src="/Images/Boostrap/Image4.png"
     class="d-block mx-auto rounded"
     alt="Centered Image">
Output:
Centered Image

9. Image Width Utilities

Bootstrap provides width utilities that can be combined with images.

<img src="/Images/Boostrap/Image1.png"
     class="w-25"
     alt="Image">

<img src="/Images/Boostrap/Image1.png"
     class="w-50"
     alt="Image">

<img src="/Images/Boostrap/Image1.png"
     class="w-75"
     alt="Image">

<img src="/Images/Boostrap/Image1.png"
     class="w-100"
     alt="Image">
25% Width 25 percent width
50% Width 50 percent width
75% Width 75 percent width
100% Width 100 percent width

10. Bootstrap Figure

Bootstrap provides figure classes for displaying an image together with a caption.

<figure class="figure">

    <img src="/Images/Boostrap/Image1.png"
         class="figure-img img-fluid rounded"
         alt="Figure Image">

    <figcaption class="figure-caption">
        Bootstrap Figure Example
    </figcaption>

</figure>
CIIT Training Institute
CIIT Training Institute - Bootstrap Image Example

11. Responsive Figure

We can combine Bootstrap's figure and responsive image classes to create a responsive figure.

<figure class="figure">

    <img src="/Images/Boostrap/Image2.png"
         class="figure-img img-fluid rounded"
         alt="Responsive Figure">

    <figcaption class="figure-caption">
        Responsive Figure
    </figcaption>

</figure>
Responsive Figure
This figure automatically adjusts to the available width.

12. CIIT Training Institute Example

Suppose CIIT Training Institute wants to display course images on its website.

<div class="text-center">

    <img src="/Images/Boostrap/Image1.png"
         class="img-fluid rounded shadow"
         alt=".NET Full Stack">

    <h4 class="mt-3">
        .NET Full Stack Development
    </h4>

</div>
.NET Full Stack Development

.NET Full Stack Development

Live Project | Internship | Interview Preparation

Important Bootstrap Image Classes

Class Purpose
.img-fluid Makes an image responsive.
.rounded Adds rounded corners.
.rounded-circle Creates a circular image.
.img-thumbnail Creates a bordered thumbnail image.
.float-start Moves the image toward the start.
.float-end Moves the image toward the end.
.d-block Makes the image a block element.
.mx-auto Helps center a block-level image.
.w-25 Sets width to 25%.
.w-50 Sets width to 50%.
.w-75 Sets width to 75%.
.w-100 Sets width to 100%.
.figure Creates a figure container.
.figure-img Styles an image inside a figure.
.figure-caption Styles the figure caption.

Common Mistakes

  • Forgetting the alt attribute.
  • Using very large images without .img-fluid.
  • Using .rounded-circle on a non-square image and expecting a perfect circle.
  • Using float-start or float-end without clearing the floating content when necessary.
  • Using fixed image dimensions that break the mobile layout.
  • Forgetting to provide meaningful alternative text for accessibility.

Summary

  • Bootstrap provides many useful classes for images.
  • .img-fluid makes images responsive.
  • .rounded creates rounded corners.
  • .rounded-circle creates circular images.
  • .img-thumbnail creates thumbnail-style images.
  • .float-start and .float-end help align images.
  • d-block mx-auto can be used to center an image.
  • Width utilities such as w-25, w-50, w-75 and w-100 control image width.
  • Bootstrap's figure classes can be used to display images with captions.