This repository demonstrates a common issue encountered when using Tailwind CSS via a CDN link: classes not being applied. The issue is resolved by using a local installation of Tailwind CSS, which correctly processes and applies the styles.
When including Tailwind CSS via a CDN link (as shown in index.html
), the styles defined by the Tailwind classes are not applied, resulting in the div element not having the expected red background.
The solution involves installing Tailwind CSS locally. This ensures that the build process correctly processes your styles and applies them to your HTML. This is done by creating a tailwind.config.js
and running the necessary Tailwind commands to setup and build the CSS.
npm init -y
to create a package.json
file.npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
@tailwind base;
@tailwind components;
and @tailwind utilities;
into your index.html
stylesheet section.tailwind.config.js
to build your CSS.This approach ensures that Tailwind CSS classes are correctly applied, resolving the styling issue.