Expert session · BCA · Marwadi University

Tailwind
CSS

Expert Talk for Students

Build good-looking, responsive web pages without leaving your HTML.

<button class="px-8 py-3 rounded-xl bg-sky-700 text-white font-semibold shadow-lg hover:-translate-y-0.5"> Let's begin </button>
renders →
Date28 November 2026
VenueMarwadi University, Rajkot
SpeakerSagar Pansuriya
Sagar Pansuriya

Sagar Pansuriya

Technical Lead & Frontend Architect

10+ years building SaaS and content platforms with Laravel, WordPress and NativePHP. Author of the open-source tailwindcss-fluid-scale plugin.

sagarpansuriya.in · @frontendbysagar

Today's plan

  1. 01FoundationsWhy utility-first, how it works, setup
  2. 02Lab 1 · First stylesHeading, button, card
  3. 03Core utilities & layoutSpacing, type, colour, flex, grid, position
  4. 04Lab 2 · LayoutsNavbar, gallery, product card
  5. 05Short breakRecharge before part two
  6. 06Responsive & interactive + Lab 3md:, hover:, group, dark mode, motion
  7. 07Real projects, quiz, Q&A@theme, reuse, plugins, mistakes

Before we start

How today works: watch, practise, ask

WATCH

Slides & live demos

Every idea is shown on screen first, usually with a live example you can see change.

PRACTISE

3 labs, 11 exercises

On your own laptop. The exercise page checks your work and tells you what is missing.

ASK

Doubts any time

Raise a hand. Each exercise also has hints, a solution and answers to common problems.

Open this on your laptop now

Chrome, Edge or Firefox + internet. Nothing to install.

sagarpansuriya.in/tailwindcss-expert-talk-for-students/exercises/

01 · Why utility-first

Plain CSS gets messy as a project grows

style.css — after one semester project

/* style.css */ .card { padding: 24px; border-radius: 12px; } .card-title { font-size: 20px; } .card-title--big { font-size: 28px; } .btn-primary { background: #0ea5e9; } .btn-primary-new { background: #0284c7; } .btn-primary-new-2 { ... } .home .sidebar .card .title { ... } /* nobody dares delete anything */

Naming everything

Every element needs a class name before you can style it. .card-title--big? .big-card-title?

Jumping between files

HTML in one tab, CSS in another, hunting for which selector wins.

CSS that only grows

Old rules might still be used somewhere, so they stay forever.

01 · Why utility-first

Tailwind is a utility-first CSS framework

Instead of writing new CSS, you combine small ready-made classes. Each class does exactly one job.

p-4padding: 1rem;
mt-8margin-top: 2rem;
flexdisplay: flex;
text-centertext-align: center;
font-boldfont-weight: 700;
rounded-lgborder-radius: 0.5rem;

Spacing follows one scale: 1 unit = 0.25rem (4px), so p-4 = 16px and mt-8 = 32px.

01 · Why utility-first

Same button, two ways

Traditional: HTML + a CSS file

<button class="btn">Enroll</button> .btn { background: #0369a1; color: white; padding: 8px 16px; border-radius: 8px; font-weight: 600; } .btn:hover { background: #075985; }

Tailwind: everything in the HTML

<button class="bg-sky-700 text-white px-4 py-2 rounded-lg font-semibold hover:bg-sky-800"> Enroll </button> /* no CSS file to write */

Same result. No class name to invent, no second file, and the styling is visible where it is used.

01 · Why utility-first

A short history of Tailwind

Created by Adam Wathan and team. It started as a side project and grew into one of the most widely used CSS frameworks.

2017

First release

The utility-first idea goes public.

2019

v1.0

First stable version for real projects.

2021

v3

On-demand engine: CSS is generated only for classes you use.

2025

v4 · today

Rebuilt, faster engine. Configuration moves into CSS.

Everything today is v4. Online tutorials are often v3 — mostly the same classes, but set up differently.

01 · Why utility-first

How Tailwind builds your CSS

STEP 1

You write classes

In HTML, JavaScript, JSX, Vue… any file in your project.

→

STEP 2

Tailwind scans

It reads your files and collects every class name it finds.

→

STEP 3

Only those ship

The final CSS has just the classes you used. Nothing unused.

⚠ The one gotcha

Tailwind reads files as plain text. It cannot run your code, so build class names in full.

won't work class="bg-${color}-500"
works const colors = { red: 'bg-red-500', blue: 'bg-blue-500' }

02 · Set up in 2 minutes

Two ways to start

A · Play CDN

for practice

One script tag. No install. Perfect for labs and trying things out.

<head> <script src="https://cdn.jsdelivr.net/npm/ @tailwindcss/browser@4"></script> </head> <body> <h1 class="text-3xl font-bold text-sky-700"> Hello, Marwadi! </h1> </body>

Write the src URL on one line — it is split here only to fit.

B · Vite project

for real apps
# 1. install npm install tailwindcss @tailwindcss/vite
// 2. vite.config.js import { defineConfig } from 'vite' import tailwindcss from '@tailwindcss/vite' export default defineConfig({ plugins: [tailwindcss()], })
/* 3. src/style.css */ @import "tailwindcss";

02 · Set up in 2 minutes

No framework? The Tailwind CLI

# 1. in an empty project folder npm install tailwindcss @tailwindcss/cli
/* 2. src/input.css */ @import "tailwindcss";
# 3. build, and rebuild on every save npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css --watch
<!-- 4. src/index.html --> <link href="./output.css" rel="stylesheet">

Needs Node.js — check with node -v. Works with plain HTML, JavaScript, PHP… any files.

Two editor tools worth installing

Tailwind CSS IntelliSense

VS Code extension: autocomplete, colour previews, and hover to see the real CSS of any class.

prettier-plugin-tailwindcss

Sorts classes into a consistent order every time you save. Fewer arguments in code review.

Lab 1 · 15 minutes

Your first styles

EXERCISE 1

Hello Tailwind

Style a heading and paragraph: size, weight, colour, spacing.

EXERCISE 2

A real button

Padding, rounded corners, colours and a hover state.

EXERCISE 3

Notice card

A white card with padding, border radius and a shadow.

Open

sagarpansuriya.in/tailwindcss-expert-talk-for-students/exercises/

Press Check my work to see what is missing. Stuck? Use Hint, or raise your hand.

15:00

03 · Core utilities

The classes you will use every day

Category Examples What they control
Spacing p-4 · px-6 · mt-8 · gap-4 Padding, margin, gaps between items
Sizing w-full · h-12 · max-w-md · size-10 Width, height, maximum width
Typography text-xl · font-bold · text-center Font size, weight, alignment
Colours text-slate-700 · bg-sky-500 Text and background; shades 50 to 950
Borders border · rounded-lg · shadow-md Borders, rounded corners, shadows
Layout flex · grid · items-center Flexbox and grid (next slide)

03 · Core utilities

Spacing & sizing: one scale for everything

p-1
4px
p-2
8px
p-4
16px
p-6
24px
p-8
32px
p-12
48px
p-16
64px

Pick a side

p all · px left+right · py top+bottom · pt pr pb pl one side. Margin works the same: m mx my mt…

Handy extras

mx-auto centres a block · -mt-4 negative margin · space-y-4 gap between stacked children

Sizes

w-64 · w-1/2 · w-full · max-w-xl · min-h-screen · size-12

03 · Core utilities

Typography

text-smThe quick brown fox · 14px
text-baseThe quick brown fox · 16px
text-xlThe quick brown fox · 20px
text-3xlThe quick brown fox
text-5xlQuick fox
font-light … font-blackWeight 300 → 900
leading-relaxedLine height
tracking-wideLetter spacing
uppercase · italicCase and style
truncateOne line with …
line-clamp-2Cut after 2 lines
text-balanceEven heading lines

03 · Core utilities

Colours: a family and a shade

bg-sky-500 = background · family sky · shade 500. Every family has 11 shades, from 50 (lightest) to 950 (darkest).

50
100
200
300
400
500
600
700
800
900
950

Same colour, any property

text- bg- border- ring- shadow- + sky-700

Opacity with a slash

bg-sky-500/50 = 50% transparent background

Gradients

bg-linear-to-r from-sky-500 to-indigo-500

03 · Core utilities

Borders, rounded corners & shadows

rounded-none
rounded-md
rounded-xl
rounded-full
border-2 border-sky-400
border-dashed
shadow-lg
ring-4 ring-sky-400/60

Pick a side here too: border-b, rounded-t-xl. A ring is an outline that does not change the layout — perfect for focus states.

03 · Core utilities

Layout with flex and grid

Flex · one direction

Line items up in a row or a column. Great for navbars and toolbars.

<nav class="flex items-center justify-between gap-4">

Grid · rows and columns

Place items in a two-dimensional grid. Great for cards and galleries.

<div class="grid grid-cols-3 gap-4">
1
2
3
4
5
6

03 · Core utilities

Flexbox in detail

ClassWhat it does
flex · flex-colRow (default) or column
justify-start | center | betweenSpread along the main direction
items-start | center | stretchAlign across it
gap-4Space between items
flex-wrapAllow a new line
flex-1 · shrink-0Fill space · never squash

The classic question: how do I centre a div?

<div class="flex items-center justify-center min-h-screen">

or, even shorter:

<div class="grid place-items-center min-h-screen">
centred ✓

03 · Core utilities

Grid in detail: page layouts

<div class="grid grid-cols-12 gap-6"> <aside class="col-span-3">Menu</aside> <main class="col-span-9">Content</main> <footer class="col-span-12">Footer</footer> </div>
col-span-3
col-span-9
col-span-12

12 columns

Split the page into 12 equal parts. 3 + 9, 4 + 8, 6 + 6… it divides in many ways.

Rows too

grid-rows-3 and row-span-2 for tall tiles in a gallery.

Gaps

gap-6 both ways, or gap-x-8 gap-y-4 separately.

03 · Core utilities

Positioning: badges, overlays, sticky headers

<div class="relative rounded-xl bg-white p-6"> <span class="absolute top-3 right-3 rounded-full bg-rose-500 px-3 text-white">NEW</span> <h3>Web Development Course</h3> </div>
Web Development Course NEW
relative"Pin children to me"
absolutePin to nearest relative parent
top-3 right-3Offset from the edges
inset-0Cover the whole parent
z-10 · z-50Which layer is on top
sticky top-0Header that stays on scroll

Lab 2 · 20 minutes

Build real layouts

EXERCISE 4

College navbar

Logo left, links right, everything vertically centred.

EXERCISE 5

Photo gallery

A 3-column grid of tiles with even gaps.

EXERCISE 6

Course card with badge

Pin a "NEW" badge to the corner with relative + absolute.

Same page as before

sagarpansuriya.in/tailwindcss-expert-talk-for-students/exercises/

Your Lab 1 work is saved in your browser — just continue.

20:00

Break

Short break ☕

10:00

After the break: responsive design, hover & focus, dark mode and animation.

04 · Responsive, states, theming

Responsive: mobile first, then add prefixes

(none)all screens
sm:≥ 640px
md:≥ 768px
lg:≥ 1024px
xl:≥ 1280px
2xl:≥ 1536px

Unprefixed classes apply everywhere. A prefix means "from this width and up".

grid-cols-1 sm:grid-cols-2 lg:grid-cols-4
375px

04 · Responsive, states, theming

Four responsive patterns you will use all the time

Stack on phone, side by side on laptop

class="flex flex-col md:flex-row gap-6"

Show or hide by screen size

class="hidden md:block" desktop only class="md:hidden" mobile only

Bigger text on bigger screens

class="text-2xl md:text-4xl lg:text-6xl"

Only below a size, or between two

class="max-md:px-4" < 768px class="md:max-lg:grid-cols-2" 768–1023

04 · Responsive, states, theming

Container queries: respond to the box, not the screen

The same card can sit in a narrow sidebar and a wide main area. With container queries it adapts to wherever it is placed.

<div class="@container"> <div class="flex flex-col @md:flex-row gap-4"> <img class="@md:w-48" …> <p>Course details…</p> </div> </div>

@container marks the parent. @md: means "when that box is at least 28rem wide". Built into v4 — no plugin.

in a narrow sidebar

in a wide main area

04 · Responsive, states, theming

States with variants: hover: focus: dark:

hover:bg-sky-800

Applies only while the mouse is over the element.

focus:ring-4

Applies when an input is selected — vital for keyboard users.

dark:bg-slate-800

Applies in dark mode. Variants stack: md:hover:underline

live · try it

04 · Responsive, states, theming

Style a child from its parent: group & peer

hover the card → the arrow moves

<a class="group rounded-xl bg-white p-6 hover:bg-sky-50"> Register for the workshop <span class="group-hover:translate-x-2 …">→</span> </a>

bad email → the message appears

<input type="email" class="peer …"> <p class="hidden peer-invalid:block text-rose-600"> Please enter a valid email </p>

group goes on the parent. peer goes on an earlier sibling.

live · try it

04 · Responsive, states, theming

Transitions & animation

Smooth changes

transition duration-300 ease-out + hover:scale-105 or hover:-translate-y-1

Ready-made animations

animate-spin loaders · animate-ping notification dots · animate-pulse skeletons · animate-bounce arrows

Be kind

motion-reduce:animate-none respects users who turn animation off.

live

04 · Responsive, states, theming

Accessible by default: four habits

sr-only

Text for screen readers only — e.g. a label for an icon-only button.

<span class="sr-only">Close menu</span>

focus-visible:

Shows a ring for keyboard users without showing it on mouse clicks.

"focus-visible:ring-4 ring-sky-300"

Contrast

Light text on light colours is hard to read. Use text-white on 700+ shades, dark text on 50–300.

Never remove outlines

If you add outline-none, always add a focus: style to replace it.

Lab 3 · 25 minutes

Make it responsive and interactive

EXERCISE 7

Responsive pricing

1 column on phones, 3 on laptops. Use the preview size buttons.

EXERCISE 8

Login form

Focus rings, full-width button, an error that shows with peer-invalid.

EXERCISE 9

Dark mode event card

Add dark: styles, then a group-hover effect.

Exercises page

sagarpansuriya.in/tailwindcss-expert-talk-for-students/exercises/

Finished early? Start the Final challenge (exercises 10 and 11).

25:00

04 · Responsive, states, theming

Make it yours with @theme

src/style.css

@import "tailwindcss"; @theme { --color-brand: #0f766e; --font-display: "Poppins", sans-serif; --breakpoint-3xl: 1920px; }

index.html

<h1 class="font-display text-brand 3xl:text-6xl">

One variable, many classes

--color-brand creates bg-brand, text-brand, border-brand…

Config lives in CSS

Tailwind v4 needs no tailwind.config.js. Older v3 tutorials use one — that is the difference.

05 · Real projects

Need an exact value? Use square brackets

ClassGenerates
w-[327px]width: 327px
bg-[#1da1f2]a colour that is not in the palette
grid-cols-[240px_1fr]fixed sidebar + flexible content (_ = space)
top-[calc(100%+8px)]any CSS value, even calc()

Use them sparingly

If you type the same bracket value three times, it belongs in @theme — so the whole team gets a proper class name.

05 · Real projects

"The same 12 classes on every button?" — reuse them

first choice a component or function — JS, React, Vue…

// button.js — write the classes once const btn = 'rounded-lg bg-sky-700 px-4 py-2 font-semibold text-white hover:bg-sky-800'; function Button(label) { return `<button class="${btn}">${label}</button>`; } // use it anywhere list.innerHTML += Button('Enroll');

sometimes @apply in CSS

@layer components { .btn { @apply rounded-lg bg-sky-700 px-4 py-2 font-semibold text-white; } }

Why components first?

@apply brings back naming and a second file — the problems we started with. Use it for small things like third-party HTML you cannot edit.

05 · Real projects

Plugins & component libraries

add a plugin in your CSS

@import "tailwindcss"; @plugin "@tailwindcss/typography"; @plugin "@tailwindcss/forms";
<article class="prose lg:prose-xl"> <!-- blog post from a CMS: nicely styled --> </article>

@tailwindcss/typography

One prose class styles a whole article: headings, lists, links, quotes.

@tailwindcss/forms

Sensible default styles for inputs, selects and checkboxes.

Component libraries

daisyUI, Flowbite, shadcn/ui and others give you ready-made buttons, modals and navbars built on Tailwind.

05 · Real projects

Common mistakes (and quick fixes)

MistakeWhat happensFix
Building class namesbg-${color}-500 has no CSSWrite full class names
Using sm: for phonesStyle shows on laptops onlyNo prefix = phone
Two classes that clashp-4 p-8: which wins is unclearUse only one
No viewport meta tagPhone zooms out, breakpoints failAdd it to every page
Following v3 tutorialstailwind.config.js missingUse @theme in v4
TyposNothing happens, no errorInstall IntelliSense

06 · Build live

Your turn: change a class, see it live

preview

06 · Build live

Build it: a student profile card

result

Wrap-up

Is Tailwind right for your project?

✓ Strengths

Fast to build — no switching between files.

Consistent design — spacing and colours come from one scale.

Small CSS — only the classes you use are shipped.

Built in — responsive, hover, focus and dark mode.

− Trade-offs

Long class lists — HTML can look busy at first.

Class names to learn — the editor extension helps a lot.

You still need CSS — Tailwind is CSS with short names.

Repetition — move repeated markup into components or partials.

Wrap-up

Turn today into a portfolio

WEEK 1

Clone a page you like

Pick a landing page and rebuild it with Tailwind. Copying real designs is the fastest way to learn.

WEEK 2

Your portfolio site

About, projects, contact. Responsive and with dark mode. Host it free on GitHub Pages.

WEEK 3+

A real app

Use Tailwind in your semester project — HTML, JavaScript or React. Mention it on your CV.

Attention check

Quick quiz — who was listening?

Question 1Score: 0/0

Homework

Practise this week, then thank you!

EXERCISE 10

Student profile card

Rebuild today's live demo from memory, then make it yours.

EXERCISE 11

Hero section

A full landing-page hero: responsive, gradient, two buttons.

ALWAYS ONLINE

Exercises page

sagarpansuriya.in/tailwindcss-expert-talk-for-students/exercises/

Resources

tailwindcss.com/docs — official docs, searchable
play.tailwindcss.com — online playground, nothing to install
Tailwind CSS IntelliSense — VS Code extension for autocomplete

Questions? Stay in touch

sagarpansuriya.in
github.com/theunwindfront
@frontendbysagar

Tailwind CSS Expert Talk for Students · Marwadi University · 28 Nov 2026 01 / 17
Speaker notes