How do i make Tailwind css work with .php file?

Viewed 137

I have an issue with tailwind css not working with php files but the same works with html file. When i change the extension to .html it starts working. What shall i do? I installed tailwind css using npm and followed every step mentioned in the tailwind documentation. I am new to tailwind css. Please help.

2 Answers

Put the cdn in head of your website

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
  <h1 class="text-3xl font-bold underline">
    Hello world!
  </h1>
</body>
</html>

Documentation: https://tailwindcss.com/docs/installation/play-cdn

EDIT:

You can dowload the script that is showing (CTRL+S) when you go here: https://cdn.tailwindcss.com/3.1.8

EDIT:

IF still not working, you can check the console, maybe a cors policy.

You should check out this youtube video at: https://www.youtube.com/watch?v=dPVotANrEYI. Your tailwind.config file should look something like this:

 /** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,js,php}"],
  theme: {
    extend: {},
  },
  plugins: [],
}
Related