Installing Tailwind Via Cdn Postcss Cli in TailwindCSS
Here's a breakdown of the three main ways to install Tailwind CSS: via CDN, PostCSS, and CLI—with examples for each.
? 1. Install via CDN (Quickest for Prototyping)
Use this when you want to test or prototype Tailwind quickly without a build step.
? How:
<!DOCTYPE html><html><head> <script src="https://cdn.tailwindcss.com"></script></head><body> <div class="text-center text-2xl font-bold text-blue-600"> Hello Tailwind! </div></body></html>?? Limitations:
Not customizable (
tailwind.config.jswon’t work).Includes entire Tailwind ? larger file size.
Best for demos, not production.
? 2. Install via PostCSS (Flexible but Manual)
Use this if you're integrating Tailwind into an existing PostCSS workflow (e.g., with Webpack, Laravel Mix, etc.)
? Install Tailwind and PostCSS:
npm install tailwindcss postcss autoprefixernpx tailwindcss init? postcss.config.js
module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, },};? tailwind.config.js (generated)
Customize theme, colors, etc. here.
? Input CSS (src/input.css)
@tailwind base;@tailwind components;@tailwind utilities;?? Build the CSS:
npx postcss src/input.css -o dist/output.css? Use in HTML:
<link rel="stylesheet" href="dist/output.css">? 3. Install via Tailwind CLI (Recommended for Most Projects)
Best for new projects. Includes JIT, Purge, and fast dev server support.
?? Setup:
# Create a new projectmkdir my-tailwind-projectcd my-tailwind-projectnpm init -y# Install Tailwind CLInpm install -D tailwindcssnpx tailwindcss init? Add Tailwind to your CSS:
Create src/input.css:
@tailwind base;@tailwind components;@tailwind utilities;? Build Tailwind (once or watch mode):
# One-time buildnpx tailwindcss -i ./src/input.css -o ./dist/output.css# Or watch for changesnpx tailwindcss -i ./src/input.css -o ./dist/output.css --watch? Use in HTML:
<link rel="stylesheet" href="dist/output.css">? Summary
| Method | Use Case | Custom Config | Production Ready | Speed |
|---|---|---|---|---|
| CDN | Quick test, no build tools | ? | ? | Fastest |
| PostCSS | Existing build tools | ? | ? | Moderate |
| CLI | New/custom projects | ? | ? | ? Fast + JIT |
Would you like me to generate a ready-to-use project template for one of these methods?