bootstrap
  1. bootstrap-images

Bootstrap Images

Bootstrap makes it easy to add images to your website and make them responsive.

Syntax

To add an image to your HTML file using Bootstrap, use the following code:

<img src="image.jpg" class="img-fluid" alt="Responsive image">

Example

Here is an example of how to add an image using Bootstrap

<img src="https://static.additionalsheet.com/images//others/lucy.jpg" class="img-fluid" alt="Responsive image">
Try Playground

Rounded Image

<img src="https://static.additionalsheet.com/images//others/lucy.jpg"  class="img-fluid rounded" alt="Rounded image">
Try Playground

Circular Image

<img src="https://static.additionalsheet.com/images//others/lucy.jpg"  class="img-fluid rounded-circle" alt="Circular image">
Try Playground

Square Image

<img src="https://static.additionalsheet.com/images//others/lucy.jpg" class="img-fluid square" alt="Square image">
Try Playground

Thumbnail Image

<img src="https://static.additionalsheet.com/images//others/lucy.jpg" class="img-thumbnail" alt="Thumbnail image">
Try Playground

Explanation

In the code above, we used the img-fluid class to make the image responsive. This class tells Bootstrap to make the image fluid and adjust to the width of the screen. The alt attribute is used to provide alternative text for the image.

Use

Bootstrap's image classes can be used to create a variety of image formats, such as rounded images, circle images, and square images. These classes can be applied to the img element as follows:

  • .rounded: adds rounded corners to the image
  • .rounded-circle: creates a circular image
  • .square: makes the image square

Important Points

  • Bootstrap provides a class to make images responsive (img-fluid).
  • Additional classes can be used to create rounded, circular, or square images.
  • The alt attribute should always be used for images to provide alternative text for screen readers and improve accessibility.

Summary

Bootstrap's image classes make it easy to create a variety of image formats and ensure they are responsive and accessible. It is important to always use the alt attribute to provide alternative text for the image and improve accessibility.

Published on: