Expert session · BCA · Marwadi University
Expert Talk for Students
Build good-looking, responsive web pages without leaving your HTML.
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
Before we start
WATCH
Every idea is shown on screen first, usually with a live example you can see change.
PRACTISE
On your own laptop. The exercise page checks your work and tells you what is missing.
ASK
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
style.css — after one semester project
Every element needs a class name before you can style it. .card-title--big?
.big-card-title?
HTML in one tab, CSS in another, hunting for which selector wins.
Old rules might still be used somewhere, so they stay forever.
01 · Why utility-first
Instead of writing new CSS, you combine small ready-made classes. Each class does exactly one job.
Spacing follows one scale: 1 unit = 0.25rem (4px), so
p-4 = 16px and mt-8 = 32px.
01 · Why utility-first
Traditional: HTML + a CSS file
Tailwind: everything in the HTML
Same result. No class name to invent, no second file, and the styling is visible where it is used.
01 · Why utility-first
Created by Adam Wathan and team. It started as a side project and grew into one of the most widely used CSS frameworks.
2017
The utility-first idea goes public.
2019
First stable version for real projects.
2021
On-demand engine: CSS is generated only for classes you use.
2025
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
STEP 1
In HTML, JavaScript, JSX, Vue… any file in your project.
STEP 2
It reads your files and collects every class name it finds.
STEP 3
The final CSS has just the classes you used. Nothing unused.
Tailwind reads files as plain text. It cannot run your code, so build class names in full.
02 · Set up in 2 minutes
One script tag. No install. Perfect for labs and trying things out.
Write the src URL on one line — it is split here only to fit.
02 · Set up in 2 minutes
Needs Node.js — check with node -v.
Works with plain HTML, JavaScript, PHP… any files.
Two editor tools worth installing
VS Code extension: autocomplete, colour previews, and hover to see the real CSS of any class.
Sorts classes into a consistent order every time you save. Fewer arguments in code review.
Lab 1 · 15 minutes
EXERCISE 1
Style a heading and paragraph: size, weight, colour, spacing.
EXERCISE 2
Padding, rounded corners, colours and a hover state.
EXERCISE 3
A white card with padding, border radius and a shadow.
Open
Press Check my work to see what is missing. Stuck? Use Hint, or raise your hand.
03 · Core utilities
| 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
p all · px left+right · py top+bottom
· pt pr pb pl one side. Margin works the same: m mx my mt…
mx-auto centres a block · -mt-4 negative margin ·
space-y-4 gap between stacked children
w-64 · w-1/2 · w-full ·
max-w-xl · min-h-screen · size-12
03 · Core utilities
| font-light … font-black | Weight 300 → 900 |
| leading-relaxed | Line height |
| tracking-wide | Letter spacing |
| uppercase · italic | Case and style |
| truncate | One line with … |
| line-clamp-2 | Cut after 2 lines |
| text-balance | Even heading lines |
03 · Core utilities
bg-sky-500 = background · family sky · shade 500. Every
family has 11 shades, from 50 (lightest) to 950 (darkest).
text- bg- border- ring-
shadow- + sky-700
bg-sky-500/50 = 50% transparent background
bg-linear-to-r from-sky-500 to-indigo-500
03 · Core utilities
rounded-nonerounded-mdrounded-xlrounded-fullborder-2 border-sky-400border-dashedshadow-lgring-4 ring-sky-400/60Pick 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
Line items up in a row or a column. Great for navbars and toolbars.
Place items in a two-dimensional grid. Great for cards and galleries.
03 · Core utilities
| Class | What it does |
|---|---|
| flex · flex-col | Row (default) or column |
| justify-start | center | between | Spread along the main direction |
| items-start | center | stretch | Align across it |
| gap-4 | Space between items |
| flex-wrap | Allow a new line |
| flex-1 · shrink-0 | Fill space · never squash |
The classic question: how do I centre a div?
or, even shorter:
03 · Core utilities
Split the page into 12 equal parts. 3 + 9, 4 + 8, 6 + 6… it divides in many ways.
grid-rows-3 and row-span-2 for tall tiles in a gallery.
gap-6 both ways, or gap-x-8 gap-y-4 separately.
03 · Core utilities
| relative | "Pin children to me" |
| absolute | Pin to nearest relative parent |
| top-3 right-3 | Offset from the edges |
| inset-0 | Cover the whole parent |
| z-10 · z-50 | Which layer is on top |
| sticky top-0 | Header that stays on scroll |
Lab 2 · 20 minutes
EXERCISE 4
Logo left, links right, everything vertically centred.
EXERCISE 5
A 3-column grid of tiles with even gaps.
EXERCISE 6
Pin a "NEW" badge to the corner with relative + absolute.
Same page as before
Your Lab 1 work is saved in your browser — just continue.
Break
After the break: responsive design, hover & focus, dark mode and animation.
04 · Responsive, states, theming
Unprefixed classes apply everywhere. A prefix means "from this width and up".
04 · Responsive, states, theming
04 · Responsive, states, theming
The same card can sit in a narrow sidebar and a wide main area. With container queries it adapts to wherever it is placed.
@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
hover: focus: dark:hover:bg-sky-800Applies only while the mouse is over the element.
focus:ring-4Applies when an input is selected — vital for keyboard users.
dark:bg-slate-800Applies in dark mode. Variants stack: md:hover:underline
04 · Responsive, states, theming
group & peerhover the card → the arrow moves
bad email → the message appears
group goes on the parent.
peer goes on an earlier sibling.
04 · Responsive, states, theming
transition duration-300 ease-out +
hover:scale-105 or hover:-translate-y-1
animate-spin loaders · animate-ping notification dots ·
animate-pulse skeletons · animate-bounce arrows
motion-reduce:animate-none respects users who turn animation off.
04 · Responsive, states, theming
sr-onlyText for screen readers only — e.g. a label for an icon-only button.
focus-visible:Shows a ring for keyboard users without showing it on mouse clicks.
Light text on light colours is hard to read. Use text-white on 700+ shades,
dark text on 50–300.
If you add outline-none, always add a focus: style to
replace it.
Lab 3 · 25 minutes
EXERCISE 7
1 column on phones, 3 on laptops. Use the preview size buttons.
EXERCISE 8
Focus rings, full-width button, an error that shows with peer-invalid.
EXERCISE 9
Add dark: styles, then a group-hover effect.
Exercises page
Finished early? Start the Final challenge (exercises 10 and 11).
04 · Responsive, states, theming
src/style.css
index.html
--color-brand creates bg-brand, text-brand,
border-brand…
Tailwind v4 needs no tailwind.config.js. Older v3 tutorials use one — that is
the difference.
05 · Real projects
| Class | Generates |
|---|---|
| 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() |
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
first choice a component or function — JS, React, Vue…
sometimes @apply in CSS
@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
add a plugin in your CSS
One prose class styles a whole article: headings, lists, links, quotes.
Sensible default styles for inputs, selects and checkboxes.
daisyUI, Flowbite, shadcn/ui and others give you ready-made buttons, modals and navbars built on Tailwind.
05 · Real projects
| Mistake | What happens | Fix |
|---|---|---|
| Building class names | bg-${color}-500 has no CSS | Write full class names |
| Using sm: for phones | Style shows on laptops only | No prefix = phone |
| Two classes that clash | p-4 p-8: which wins is unclear | Use only one |
| No viewport meta tag | Phone zooms out, breakpoints fail | Add it to every page |
| Following v3 tutorials | tailwind.config.js missing | Use @theme in v4 |
| Typos | Nothing happens, no error | Install IntelliSense |
06 · Build live
06 · Build live
BCA · Semester 5
Wrap-up
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.
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
WEEK 1
Pick a landing page and rebuild it with Tailwind. Copying real designs is the fastest way to learn.
WEEK 2
About, projects, contact. Responsive and with dark mode. Host it free on GitHub Pages.
WEEK 3+
Use Tailwind in your semester project — HTML, JavaScript or React. Mention it on your CV.
Attention check
Homework
EXERCISE 10
Rebuild today's live demo from memory, then make it yours.
EXERCISE 11
A full landing-page hero: responsive, gradient, two buttons.
ALWAYS ONLINE
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