agyanadda@gmail.com

Tailwind Responsive Design

Tailwind Basics 1 min read Updated Dec 1, 2026 Topic 4 of 27

Every Tailwind class can be made responsive with a breakpoint prefix.

Prefix Min width
sm: 640px
md: 768px
lg: 1024px
xl: 1280px
2xl: 1536px

Mobile-first

Classes without a prefix apply to all screens. Prefixed classes apply from that size and up.

<div class="text-center md:text-left">

Centred on phones, left-aligned from tablets up.

Common patterns

  • Stack on mobile, row on desktop: flex flex-col md:flex-row
  • Grid columns: grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4
  • Hide on mobile: hidden md:block
  • Show only on mobile: md:hidden

Max-width variants

max-md: applies below a breakpoint, e.g. max-md:p-2.

Example

Example — Responsive layout HTML
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

<div class="p-4">
  <h1 class="text-2xl md:text-4xl font-bold text-center md:text-left">Resize the preview</h1>
  <p class="md:hidden mt-2 text-rose-600">You are on a small screen.</p>
  <p class="hidden md:block mt-2 text-emerald-600">You are on a medium or larger screen.</p>

  <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mt-6">
    <div class="bg-sky-500 text-white p-6 rounded-lg">1</div>
    <div class="bg-sky-500 text-white p-6 rounded-lg">2</div>
    <div class="bg-sky-500 text-white p-6 rounded-lg">3</div>
    <div class="bg-sky-500 text-white p-6 rounded-lg">4</div>
  </div>
</div>

Test Yourself With Exercises

Exercise 1 Multiple Choice

From which width does md: apply?

Exercise 2 True / False

A class without a prefix applies to all screen sizes.

Exercise 3 Fill in the Blank

hidden ___:block hides an element on phones and shows it from 768px.

Frequently Asked Questions

Tailwind is mobile-first: sm: means 'from 640px and up'. For phones only, write the class without a prefix and override it with sm:.