Stop using the CDN!
Do not use the CDN for project development, and especially avoid including it in production.
Why?
The CDN generates the CSS on every single page load. This is a disadvantage for production projects because it adds extra load for every client on every page load and slows down page rendering.
Another reason is that generating TailwindCSS's CSS is not needed every time - it only needs to happen when the class names in your source files change, so it only needs to be generated once per build.
Every Tailwind plugin works this way, and a watch mode is provided for development so you don't have to manually recompile endlessly while working.
Alternatives
If you don't want to use Node and npm, then clearly it's better to choose the Standalone version. It's just an executable file that you download and run. If you choose one of these installations instead of the CDN from the start, the question wouldn't even arise, because they require at least a minimal configuration.
If you have no issues with Node and npm, in addition to the CLI, two plugins are also available - you can use either one depending on your project.
So why doesn't TailwindCSS IntelliSense work with the Play CDN?
The reason is that TailwindCSS IntelliSense detects the package.json in your project and checks the installed TailwindCSS version. Without that, it looks for a configuration file.
When using a CDN, it clearly cannot find a version number, because nothing is installed. It also won't find a configuration, because the CDN works without it - it's only published for playgrounds (for example, embedding in a StackOverflow snippet). For TailwindCSS IntelliSense to start working, you need at least a configuration. This differs between v3 and v4.
TailwindCSS v3 CDN + IntelliSense
You need a tailwind.config.js with the following content:
/** @type {import('tailwindcss').Config} */
export default {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
}
Then, you must pass the path to this file in your VSCode configuration like this:
{
"tailwindCSS.experimental.configFile": "./tailwind.config.js"
}
Of course, provide the correct path and customize it relative to your setup. Place the configuration project-specifically in {your-project}/.vscode/settings.json, so the path only applies to the current project. (You can place it globally as well, but that will affect all future projects.)
See more: Workspace settings.json location
TailwindCSS v4 CDN + IntelliSense
You need a main CSS file, e.g., main.css, with the following content:
@import "tailwindcss";
Then, you must pass the path to this file in your VSCode configuration like this:
{
"tailwindCSS.experimental.configFile": "./css/main.css"
}
Of course, provide the correct path and customize it relative to your setup. Place the configuration project-specifically in {your-project}/.vscode/settings.json, so the path only applies to the current project. (You can place it globally as well, but that will affect all future projects.)
See more: Workspace settings.json location
Other