agyanadda@gmail.com

Tailwind Installation

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

1. Play CDN (for learning)

One script tag, no build step:

<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

Great for practice and demos, but not for production — it is slower and larger.

2. Vite plugin (Laravel, React, Vue)

npm install tailwindcss @tailwindcss/vite

Add the plugin in vite.config.js:

import tailwindcss from '@tailwindcss/vite';
export default { plugins: [tailwindcss()] };

Then in your CSS file:

@import "tailwindcss";

New Laravel projects already come with Tailwind set up this way.

3. Tailwind CLI (plain HTML projects)

npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --watch

What changed in v4

  • No tailwind.config.js needed — configure in CSS with @theme
  • One line @import "tailwindcss"; replaces the old three @tailwind lines
  • Automatic detection of your template files
  • Much faster builds

Example

Example — Starter page with the Play CDN HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Tailwind Starter</title>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body class="bg-gray-50 text-gray-800">
  <main class="max-w-3xl mx-auto p-6">
    <h1 class="text-3xl font-bold underline decoration-sky-500">My Tailwind Page</h1>
    <p class="mt-3">Start building here.</p>
  </main>
</body>
</html>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which method is best only for learning and demos, not production?

Exercise 2 True / False

Tailwind v4 requires a tailwind.config.js file.

Exercise 3 Fill in the Blank

In v4, your CSS file starts with @___ "tailwindcss";

Frequently Asked Questions

Yes. Use the Tailwind CLI to watch your .php or .html files and build one output.css, then link that file.