1. Content
  2. Link


Tailwind CSS Images

Documentation and examples for opting images into all kinds of behaviors.

Images are block-level

In Tailwind, images and other replaced elements (like svg, video, canvas, and others) are display: block by default.

                  <img src="..." alt="...">

This helps to avoid unexpected alignment issues that you often run into using the browser default of display: inline.

If you ever need to make one of these elements inline instead of block, simply use the inline utility:

                  <img class="max-w-none" src="..." alt="...">

Image thumbnails

Use Width and Height utility classes to give an image fixed size.

                  <img class="w-56 h-auto" src="..." alt="...">


Use bg-fixed to fix the background image relative to the viewport.

My trip to the summit
November 16, 2021 · 4 min read

Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better?

Look. If you think this is about overdue fines and missing books, you'd better think again. This is about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld; maybe that's how y'get your kicks. You and your good-time buddies.

                  <div class="bg-fixed ..." style="background-image: url(...)"></div>


Use bg-local to scroll the background image with the container and the viewport.

"Refreshing and Thought provoking design and it changes my view about how I design the websites. Great typography, modern clean white design, nice tones of the color."

— Customer
                  <div class="bg-local ..." style="background-image: url(...)"></div>


Use bg-scroll to scroll the background image with the viewport, but not with the container.

"Because the mail never stops. It just keeps coming and coming and coming, there's never a let-up. It's relentless. Every day it piles up more and more and more. And you gotta get it out but the more you get it out the more it keeps coming in. And then the barcode reader breaks and it's Publisher's Clearing House day."

— Newman
                  <div class="bg-scroll ..." style="background-image: url(...)"></div>

Setting the background position

Use bg-{side} utilities to control the position of an element’s background image.


Image Description


Image Description


Image Description


Image Description


Image Description


Image Description


Image Description


Image Description


Image Description
                  <div class="bg-no-repeat bg-left-top ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-top ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-right-top ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-left ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-center ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-right ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-left-bottom ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-bottom ..." style="background-image: url(...);"></div>
                  <div class="bg-no-repeat bg-right-bottom ..." style="background-image: url(...);"></div>


Use bg-auto to display the background image at its default size.

                  <div class="bg-auto bg-no-repeat bg-center ..." style="background-image: url(...)"></div>


Use bg-cover to scale the background image until it fills the background layer.

                  <div class="bg-cover bg-center ..." style="background-image: url(...)"></div>


Use bg-contain to scale the background image to the outer edges without cropping or stretching.

                  <div class="bg-contain bg-center ..." style="background-image: url(...)"></div>


Use h-screen to scale the background image to full screen.

                  <div class="h-screen bg-cover bg-center ..." style="background-image: url(...)"></div>

Resizing to cover a container

Resize an element’s content to cover its container using object-cover.

Image Description
                  <div class="bg-white ...">
                    <img class="object-cover h-48 w-96 ..." alt="...">

Containing an element

Resize an element’s content to stay contained within its container using object-contain.

Image Description
                  <div class="bg-white ...">
                    <img class="object-contain h-48 w-96 ..." alt="...">

Stretching to fit a container

Stretch an element’s content to fit its container using object-fill.

Image Description
                  <div class="bg-white ...">
                    <img class="object-fill h-48 w-96 ..." alt="...">

Scaling down if too large

Display an element’s content at its original size but scale it down to fit its container if necessary using object-scale-down.

Image Description
                  <div class="bg-white ...">
                    <img class="object-scale-down h-48 w-96 ..." alt="...">

Using an element’s original size

Display an element’s content at its original size ignoring the container size using object-none.

Image Description
                  <div class="bg-white ...">
                    <img class="object-none h-48 w-96 ..." alt="...">


Use scale-{percentage} to scale the image on hover.

Image Description

Overlay image

Overlay image example.

Masonry example with overlay

Masonry example with overlay.