Tailwind CSS Exercises

    Your code

    Live preview

    fit

    Check my work

    The checker looks at the real rendered result, so any correct solution passes — not just the one in the answer.

      What you are aiming for

      Stuck? Common doubts for this exercise

      Common doubts about Tailwind

      I added a class but nothing changes. Why?

      Check three things: (1) spelling — text-sky700 is not a class, text-sky-700 is; (2) your internet connection — the preview loads Tailwind from a CDN; (3) two classes fighting over the same property, like p-4 p-8 — keep only one.

      What is the difference between p-4, px-4 and pt-4?

      p-4 adds 16px on all four sides. px-4 only left and right, py-4 only top and bottom, pt-4 only the top. Margin works the same way: m, mx, mt…

      How do I centre a div?

      On the parent: flex items-center justify-center or grid place-items-center. Give the parent a height (e.g. min-h-screen) if you also want vertical centring. To centre a block horizontally only: mx-auto plus a width like max-w-md.

      Why does sm: change my laptop layout but not my phone?

      Prefixes mean "from this width and up". sm: starts at 640px, so it applies to tablets and laptops too. Write the phone style with no prefix, then add md: or lg: for bigger screens.

      How do I use my own colour, like a brand colour?

      Quick: bg-[#1da1f2]. Better for a project: add --color-brand: #1da1f2; inside @theme in your CSS file, then use bg-brand, text-brand and so on.

      Do I need Node.js to use Tailwind?

      Not for learning: the Play CDN script works in any HTML file. For real projects, yes — install it with npm and use Vite, or the Tailwind CLI: npx @tailwindcss/cli -i input.css -o output.css --watch.

      The tutorial I found uses tailwind.config.js. Is it wrong?

      It is for Tailwind v3. Most class names are the same in v4, but setup is different: v4 uses @import "tailwindcss"; and configuration goes inside @theme in your CSS.

      Isn't writing so many classes bad practice?

      Long class lists are normal in Tailwind. To avoid repeating them, put the markup in a component (a JavaScript function, a React or Vue component, or a PHP include) and reuse that. @apply exists but should be used sparingly.

      Can I use Tailwind and Bootstrap together?

      Technically yes, but their class names and resets can clash. For a new project pick one. Tailwind gives you more design freedom; Bootstrap gives you ready-made components.

      How do I use Tailwind in a plain HTML / JavaScript project?

      Install it with npm install tailwindcss @tailwindcss/cli, put @import "tailwindcss"; in src/input.css, run npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css --watch and link output.css in your HTML. No framework needed.

      Where can I look up a class?

      tailwindcss.com/docs — press Ctrl + K and search, e.g. "padding" or "shadow". In VS Code, install the Tailwind CSS IntelliSense extension to see the real CSS when you hover a class.

      Still stuck during the session? Raise your hand — that is what the labs are for.