Performance: Image thumbnails
Image thumbnails affect page load speed and rendering performance by controlling image size and format, impacting Largest Contentful Paint (LCP).
<img src="photo-thumb.jpg" class="img-thumbnail" alt="Photo">
<img src="large-photo.jpg" class="img-thumbnail" alt="Photo">
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full-size image resized with CSS | Minimal | 1 reflow per image | High due to large decode and paint | [X] Bad |
| Properly sized thumbnail image | Minimal | 1 reflow per image | Low due to smaller decode and paint | [OK] Good |
img-thumbnail do when added to an <img> tag?img-thumbnailimg-thumbnail class in Bootstrap styles images with a border and padding to look like thumbnails.img-thumbnail. Only It adds a border and padding to create a small framed image. correctly describes the border and padding effect.img-thumbnail, not any variation.<img src='pic.jpg' class='img-thumbnail' alt='pic'> uses img-thumbnail exactly. Options A, B, and D use incorrect or non-existent class names.img-thumbnail [OK]img-thumbnail for thumbnails [OK]<img src='flower.jpg' class='img-thumbnail' alt='flower'>
img-thumbnail<img src='dog.jpg' class='img_thumbnail' alt='dog'>
img_thumbnail, but Bootstrap requires a hyphen: img-thumbnail.alt attribute is present, and src looks correct. The img tag does not require a div wrapper for thumbnails.img-thumbnail with a hyphen, not underscore. -> Option Brow and col classes places images side by side with equal width and spacing.<div class='row'><div class='col'><img src='1.jpg' class='img-thumbnail' alt='1'></div><div class='col'><img src='2.jpg' class='img-thumbnail' alt='2'></div><div class='col'><img src='3.jpg' class='img-thumbnail' alt='3'></div></div> uses row and col correctly. <div class='d-flex gap-3'><img src='1.jpg' class='img-thumbnail flex-fill' alt='1'><img src='2.jpg' class='img-thumbnail flex-fill' alt='2'><img src='3.jpg' class='img-thumbnail flex-fill' alt='3'></div> uses flex but may cause uneven sizing without container. Options B and C lack layout classes for spacing and responsiveness.Pass the test and this pattern moves unknown