Images & Figures

Documentation and examples for opting images into responsive behavior (so they never become larger than their parent elements) and add lightweight styles to them. The required alt attribute specifies an alternate text for an image if the image cannot be displayed. The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Responsive images

Images in Bootstrap are made responsive with .img-fluid. max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element.

Responsive image
<img src="//placehold.it/1005x250" class="img-fluid" alt="Responsive image">

Image thumbnails

In addition to our border-radius utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.

...
<img src="//placehold.it/300x300" alt="..." class="img-thumbnail">

Aligning images

Align images with the helper float classes or text alignment classes. block-level images can be centered using the .mx-auto margin utility class.

... ... ...
<img src="//placehold.it/200x200" class="rounded float-left" alt="...">
<img src="//placehold.it/200x200" class="rounded float-right" alt="...">
<img src="//placehold.it/200x200" class="rounded mx-auto d-block" alt="...">

Figures

Anytime you need to display a piece of content—like an image with an optional caption, consider using a figure. Use the included .figure , .figure-img and .figure-caption classes to provide some baseline styles for the HTML5 figure and figcaption elements. Images in figures have no explicit size, so be sure to add the .img-fluid class to your img to make it responsive.

A generic square placeholder image with rounded corners in a figure.
A caption for the above image.
<figure class="figure">
  <img src="//placehold.it/300x300" class="figure-img rounded" alt="A generic square placeholder image with rounded corners in a figure.">
  <figcaption class="figure-caption text-right">A caption for the above image.</figcaption>
</figure>