Images need meaningful alt text and often belong in <figure> with <figcaption>. CSS controls how they scale inside layouts.
HTML checklist
altdescribes purpose (decorative images may use emptyalt="").widthandheightattributes reduce layout shift when possible.loading="lazy"for below-the-fold images on real sites.
CSS sizing
max-width: 100%; height: auto;keeps images inside narrow columns.object-fit: coverfor cropped thumbnails in fixed boxes.
Practice
The sample uses a placeholder gradient block—replace with a real img src when you host assets. Adjust .thumb height and object-fit.
Important interview questions and answers
- Q: When is `alt=""` correct?
A: When the image is decorative and surrounding text already conveys meaning. - Q: What is layout shift related to images?
A: Browser reserves space late if dimensions unknown—provide width/height or aspect-ratio. - Q: Figure vs bare img?
A: Figure groups image + caption as one unit of meaning.