Should I still specify height and width on images when using bootstrap imp-fluid?

Viewed 28

I have read that its important to always add a height and width to images, but I'm using bootstraps img-fluid which makes the height and width responsive. So I'm curious on others opinion on this.

I'm currently doing this:

<img class="img-fluid"
 src="../images/jurassic-forest-700w.jpg"
 alt="a photo of the walkway at jurassic forest with lush greenery all around and a large brachiosaurus in the distance"
 height= 350px;
 width= 700px;
>

Do I need the height and width attributes?

1 Answers

Bootstrap 4 & 5:

Since Bootstrap 4, a few new classes regarding images have been introduced. example:

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

What does img-fluid do?

.img-fluid {
  max-width: 100%;
  height: auto;
}

Images used as thumbnails are .img-thumbnail

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.

Related