Day 3 - Image Styling

Learn how to style images with Tailwind's utility classes.


1. Responsive Images

Use w-full h-auto to make an image scale with its parent container — the Tailwind equivalent of Bootstrap's .img-fluid.

Example
Responsive image

class="w-full h-auto"

2. Object Fit Utilities

Control how an image fills its container with object-{fit}. Always pair with fixed dimensions.

object-cover
Object cover

Crops to fill. Aspect ratio kept.

object-contain
Object contain

Fits inside. May show gaps.

object-fill
Object fill

Stretches to fill. May distort.

3. Aligning Images

Float Left (float-left)
Float left

Text wraps around the image because the image is floated to the left.

Float Right (float-right)
Float right

Text wraps around the image because the image is floated to the right.

Centered (block mx-auto)
Centered image

class="block mx-auto"

4. Rounded Corners

rounded

Rounded

rounded-xl

Rounded XL

rounded-full (circle)

Circle

rounded-full (pill)

Pill

5. Image Overlays

Use relative on the container and absolute inset-0 on the overlay:

With dark overlay

Dark Overlay

With gradient overlay

Gradient Overlay

← Previous: Grid Layout Next: Utilities →